Skip to content

Add instance_name to type#21

Merged
nsorros merged 1 commit intomainfrom
type-instance-name
Nov 11, 2022
Merged

Add instance_name to type#21
nsorros merged 1 commit intomainfrom
type-instance-name

Conversation

@nsorros
Copy link
Copy Markdown
Collaborator

@nsorros nsorros commented Nov 10, 2022

Fixes #17

@nsorros nsorros changed the title Add instance_name to tpye Add instance_name to type Nov 10, 2022
Copy link
Copy Markdown
Owner

@ivyleavedtoadflax ivyleavedtoadflax left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@nsorros nsorros merged commit 609bfa2 into main Nov 11, 2022
@nsorros nsorros deleted the type-instance-name branch November 11, 2022 07:04
ivyleavedtoadflax pushed a commit that referenced this pull request Jan 18, 2026
- Remove wasabi dependency, add rich
- Update all table formatting to use rich.Table
- Add status color coding (running=green, stopped=red, etc.)
- Use Console with wide width to prevent truncation in tests
- Convert datetime objects to strings for rich rendering

Closes #21

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
ivyleavedtoadflax added a commit that referenced this pull request Jan 18, 2026
* docs: Add v0.4.0 remaining work spec

Track open GitHub issues and remaining work after v0.3.0 release:
- Critical bugs: read_config parameter, create-snapshot validation
- Security: SSH StrictHostKeyChecking
- Code quality: type hints, pagination, dependency injection

* fix: Use config_path parameter in read_config() (#51)

Previously read_config() ignored the config_path parameter and always
used the global CONFIG_PATH. This fix ensures the function uses the
provided parameter, allowing custom config paths to work correctly.

- Changed CONFIG_PATH to config_path in read_config()
- Updated test to verify the parameter is used

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: Add input validation for create-snapshot command (#15)

The create-snapshot command previously crashed with ParamValidationError
when required options were missing. This fix:

- Makes --volume-id and --name required options (using typer.Option(...))
- Sets description default to empty string instead of None
- Adds short aliases -v, -n, -d for the options
- Adds tests to verify missing required options produce helpful errors

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* security: Change SSH default to StrictHostKeyChecking=accept-new (#54)

The previous default of StrictHostKeyChecking=no was vulnerable to
MITM attacks. This fix:

- Changes default to accept-new (accepts new keys, rejects changed keys)
- Adds --no-strict-host-key flag for legacy behavior when needed
- Adds tests for both default and flag behaviors

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: Update v0.4.0 spec with completed items

Mark the following issues as completed:
- Issue #51 (partial): read_config() parameter bug fixed
- Issue #15: create-snapshot input validation completed
- Issue #54 (partial): SSH StrictHostKeyChecking=accept-new implemented

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: Add comprehensive type hints and mypy configuration (#52)

- Add mypy configuration to pyproject.toml with strict type checking
- Add boto3-stubs for EC2/ECS/STS type annotations
- Add type hints to all functions and methods
- Fix type compatibility issues with boto3 typed responses
- Add mypy type checking to CI pipeline
- Update AMI create to provide sensible defaults when name/description not provided
- Use typing.cast for wasabi.table aligns parameter (no proper stubs)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: Implement AWS API pagination for list operations

- Add pagination support to get_instances() in utils.py
- Add pagination support to get_all_clusters() in ecs.py
- Add pagination support to get_all_services() in ecs.py
- Use boto3 paginators to handle >100 items
- Update tests to mock paginators

This allows the CLI to handle accounts with large numbers of
instances, clusters, or services without missing results.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor: Implement dependency injection for AWS clients (#53)

- Add get_ec2_client() function with lru_cache for lazy initialization
- Add get_sts_client() function with lru_cache for lazy initialization
- Add get_ecs_client() function with lru_cache for lazy initialization
- Add TYPE_CHECKING imports for type annotations
- Keep backwards compatible ec2_client/ecs_client aliases

This allows for:
- Lazy initialization of AWS clients (deferred until first use)
- Easier testing by allowing function-level mocking
- Cached clients for reuse across multiple calls

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: Update spec with review findings and fix lazy client initialization

- Updated v0.4.0 spec to mark completed items (type hints, pagination, DI)
- Added 8 new issues discovered during code review:
  - HIGH: Logic bug in get_instance_by_name(), SSH subprocess error handling,
    unvalidated array index in AMI launch
  - MEDIUM: Deprecated datetime API, inconsistent output/exit patterns
  - LOW: Function shadowing builtin, test coverage improvements

- Implemented lazy client initialization using module __getattr__ for
  backwards compatibility with ec2_client and ecs_client module-level
  attributes
- Updated all source code to use get_ec2_client() and get_ecs_client()
  directly for consistent behavior
- Fixed all test mocks to properly patch getter functions where they are
  used, not where they are defined
- Added AWS_DEFAULT_REGION environment variable in conftest.py to enable
  boto3 client creation during test collection

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: Refactor specs into modular issue files

- Replace monolithic v0.4.0-remaining-work.md with index and individual specs
- Create specs/readme.md as simple instruction index
- Create separate spec files for each remaining issue (13-20)
- Organize by priority (High/Medium/Low)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: Add issue-21 spec to replace wasabi with rich

- Add spec for replacing wasabi table formatting with rich library
- Include table styling guidelines and status color coding
- Update specs/readme.md index

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: Add v0.5.0 feature specs

- issue-22: Instance pricing with AWS Price List API
- issue-23: Package rename from remotepy to remote
- issue-24: Pydantic config validation with env var support
- issue-25: Contributing guide with PR/issue templates

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* chore: Remove accidental swap file

* docs: Add issue-26 spec for template workflow improvements

Analyzes current template workflow in ami.py and instance.py.
Proposes improvements including:
- Moving list_launch_templates() to utils.py (DRY)
- Adding default_launch_template config option
- Enhanced template listing with filtering and details
- New commands: list-templates, template-versions, template-info
- Better interactive selection UX

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: Add specs for config, help, and subcommand structure

- issue-27: Config workflow improvements (set/get/unset commands, init wizard)
- issue-28: CLI help documentation improvements
- issue-29: Subcommand compartmentalization (remote instance prefix)
- Updated readme with recommended issue order by phase

Also fixed lazy client initialization in snapshot.py and volume.py
to use get_ec2_client() instead of ec2_client module attribute.
Updated corresponding test files with proper mock patterns.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: Change break to continue in get_instance_info() to prevent early loop exit

Previously, when encountering an instance without a Name tag in
get_instance_info(), the code would break out of the loop entirely,
preventing subsequent named instances in the same reservation from
being found. This changes the break to continue so all instances
are properly checked.

Added regression test to verify nameless instances don't block
finding valid instances that come after them in the same reservation.

Fixes #13

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: Add error handling for SSH subprocess in connect command

Add try-except block around subprocess.run() for SSH connections to:
- Report non-zero exit codes from SSH
- Handle FileNotFoundError when SSH client is not installed
- Handle OSError for connection issues

Also adds 4 new tests covering these SSH failure scenarios.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: Add bounds checking for array access in AMI launch template selection

Validate user input when selecting launch templates by number to prevent
IndexError. Uses validate_array_index() from validation module to ensure
the selection is within valid bounds.

Closes #15

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: Mark issue-15 as completed

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: Replace deprecated datetime.utcfromtimestamp() with timezone-aware alternative

Use datetime.fromtimestamp(..., tz=timezone.utc) instead of the deprecated
utcfromtimestamp() method which will be removed in a future Python version.

Closes #16

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: Mark issue-16 as completed

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor: Standardize exit patterns to use typer.Exit

- Replace sys.exit(1) with raise typer.Exit(1) in instance.py
- Remove unused sys import
- Remove dead typer.Exit(0) code in __main__.py version command

Closes #18

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: Mark issue-18 as completed

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor: Rename list functions to avoid shadowing Python builtin

Rename list functions to more descriptive names while keeping CLI
command names as "list" and "ls":
- instance.py: list -> list_instances
- ami.py: list -> list_amis
- snapshot.py: list -> list_snapshots
- volume.py: list -> list_volumes

Closes #19

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: Mark issue-19 as completed

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor: Replace wasabi with rich for table formatting

- Remove wasabi dependency, add rich
- Update all table formatting to use rich.Table
- Add status color coding (running=green, stopped=red, etc.)
- Use Console with wide width to prevent truncation in tests
- Convert datetime objects to strings for rich rendering

Closes #21

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: Mark issue-21 as completed

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor: Replace print() with typer.secho() in config.py for consistent output

Use typer.secho() with yellow color for warning messages to match
the output patterns used in the rest of the codebase.

Closes #17

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: Mark issue-17 as completed

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: Add help text to subcommand groups in CLI

Add descriptive help text to all subcommand groups (ami, config,
snapshot, volume, ecs) to improve discoverability and user experience.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: Add instance subcommand group with backward compatibility

- Create new main Typer app instead of using instance_app directly
- Copy instance commands to root level for backward compatibility
- Register instance_app as explicit 'instance' subcommand
- Add tests for both command paths (root and instance prefix)

Both `remote start` and `remote instance start` now work.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* chore: Update ralph prompt

* docs: Add issue-30 for removing root-level instance commands

Breaking change planned for v1.0.0 to clean up the CLI help output
by requiring the `instance` prefix for all instance commands.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: Improve CLI help documentation

- Add epilog with usage hint to main Typer app
- Fix empty description for `type` command
- Improve and standardize docstrings across all modules
- Add examples to complex commands (connect, launch, ami create, etc.)
- Standardize docstring format: brief one-line description followed by details
- Update issue-28 and issue-29 spec files with completed status

Closes #28

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: Improve config workflow with new commands

Add new config management commands:
- set: Set configuration values with validation
- get: Get single values (script-friendly, no formatting)
- unset: Remove configuration values
- init: Guided first-time setup wizard
- validate: Validate config file and check SSH key paths
- keys: List all valid configuration keys

Also adds:
- VALID_KEYS constant with supported config options
- Generic get_value/set_value/remove_value methods in ConfigManager
- Comprehensive tests for all new commands (12 new tests)

Closes #27

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: Improve launch template workflow with better commands and DRY code

- Move get_launch_templates() to utils.py to remove duplication
- Add get_launch_template_versions() utility function
- Add --filter and --details options to list-templates command
- Add template-versions command to show version history
- Add template-info command to show detailed template configuration
- Update launch commands to use default_launch_template from config
- Update tests to use new utility function mocking

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test: Add edge case tests for pagination and client caching

- Add TestPaginationEdgeCases class with tests for:
  - Empty pagination responses
  - Multiple pages of results
  - Multiple empty pages
  - Mixed empty and populated pages
  - Pagination with exclude_terminated filter
- Add TestClientCaching class with tests for:
  - EC2 client caching behavior
  - STS client caching behavior
  - Cache clearing creates new client

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: Add contributing guide and GitHub templates

- Add CONTRIBUTING.md with development setup, code style, and PR process
- Add PR template with checklist for tests, linting, and types
- Add issue templates for bug reports and feature requests
- Add badges to README (tests, Python version, license)
- Mark issue-25 as COMPLETED

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test: Add tests for ami.py to reach 85% coverage

- Add tests for list-templates with --details flag
- Add tests for launch with default template from config
- Add tests for launch when no templates found
- Add tests for template-versions command
- Add tests for template-info command
- Remove unrecognized coverage_thresholds config

Coverage increased from 78.8% to 85.2%

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: Add instance pricing to list command (#22)

Add pricing information (hourly and monthly estimates) to the `remote list`
command output using the AWS Pricing API.

Changes:
- Add new `remotepy/pricing.py` module with AWS Pricing API integration
- Cache pricing data using lru_cache to minimize API calls
- Add `--no-pricing` flag to skip pricing lookup for faster listing
- Handle unavailable pricing gracefully (shows "-" when price unknown)
- Support 17 common AWS regions with location name mapping

The pricing API is queried from us-east-1 (only available region) and
prices are cached per instance type/region combination.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor: Rename package from remotepy to remote (#23)

Rename the package directory from `remotepy/` to `remote/` to match the CLI
command name. This eliminates confusion between the package name and the
CLI command.

Changes:
- Rename `remotepy/` directory to `remote/`
- Update all imports in source files (from remotepy.* to remote.*)
- Update all imports in test files
- Update pyproject.toml entry points and build configuration
- Update coverage configuration

The PyPI distribution name remains "remotepy" for backwards compatibility.
All 314 tests pass after the rename.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test: Update mypy and pytest targets

* docs: Add status columns to spec tables and issue 31

- Add status column to all tables in specs/readme.md
- Add issue-31 spec for SSH key config not used by connect command
- Add coverage reporting to pytest pre-push hook (--cov with skip-covered)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: Add v1.0.0 release specs (issues 32, 33, 34)

- Issue 32: Rich output enhancements (tables, panels for ECS, config)
- Issue 33: v1.0.0 release preparation checklist
- Issue 34: Comprehensive security review
- Add Phase 7 (v1.0.0 Release) to recommended order
- Update priority index with new issues

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* chore: Add security checks to pre-push hooks

- Add mypy for type checking
- Add bandit for static security analysis (skip B311, B404, B603)
- Add pip-audit for dependency vulnerability scanning
- Fix vulnerable deps: filelock, urllib3, virtualenv
- Update package path from remotepy/ to remote/

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* specs: Update specs to include security scans

* feat: Connect command uses ssh_key from config

The connect command now checks for a configured ssh_key value when
the --key option is not provided. This allows users to set a default
SSH key in their config file that will be used automatically.

- Add config fallback for ssh_key in connect()
- Update help text to mention config fallback
- Add tests for config ssh_key usage
- Fix pre-push coverage config to use correct package name

Closes #31

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: Enhance output with Rich formatting

Add Rich tables and panels for improved UX in several areas:

- ECS: cluster and service selection now uses Rich tables with
  extracted names from ARNs
- Config: validation results displayed in Rich panel with colored
  status indicators
- Instance/AMI: launch summary displayed in Rich panel with
  instance details

Updated tests to account for new Rich formatting output.

Closes #32

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: Complete security review for v1.0.0

Conduct comprehensive security review covering:
- Credential handling: Uses boto3 credential chain, no hardcoded secrets
- Input validation: Array bounds checking, path sanitization
- SSH security: No shell injection, proper subprocess handling
- File system security: Config in ~/.config/, proper path handling
- Subprocess security: List arguments, no shell=True
- Dependency security: pip-audit and bandit pass
- Error handling: No sensitive data in error messages

Add SECURITY.md with:
- Security reporting process
- Security measures documentation
- Accepted risks with justification

Closes #34

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat!: Remove root-level instance commands (BREAKING CHANGE)

Remove backwards compatibility for root-level instance commands.
Instance commands now require the 'instance' prefix:

- `remote start` -> `remote instance start`
- `remote stop` -> `remote instance stop`
- `remote connect` -> `remote instance connect`
- `remote list` -> `remote instance list`

This provides a cleaner CLI structure with no duplicate commands
in the help output.

BREAKING CHANGE: Root-level instance commands removed. Use
`remote instance <command>` instead.

Closes #30

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* chore: Prepare v1.0.0 release

- Bump version to 1.0.0
- Update development status to Production/Stable
- Add CHANGELOG.md with complete version history
- Update README with migration guide and v1.0.0 command syntax
- Update test count references to 317+

This marks the first stable release with:
- Complete security review
- All planned features implemented
- Breaking change to require 'instance' prefix for commands
- Comprehensive test coverage

Closes #33

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Ubuntu <ubuntu@ip-172-31-41-169.eu-west-1.compute.internal>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
ivyleavedtoadflax added a commit that referenced this pull request Jan 18, 2026
…idate-output

fix: Remove hardcoded console width and simplify validate output
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.

Make type accept instance name like the other commands

2 participants