Metadata-Version: 2.4
Name: migs
Version: 0.1.3
Summary: CLI tool for managing Google Cloud Managed Instance Groups
Author-email: Keaton Elvins <keatone@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/keatonelvins/migs
Project-URL: Documentation, https://github.com/keatonelvins/migs#readme
Project-URL: Repository, https://github.com/keatonelvins/migs.git
Project-URL: Issues, https://github.com/keatonelvins/migs/issues
Keywords: gcloud,google-cloud,mig,managed-instance-groups,cli
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Systems Administration
Classifier: Topic :: Utilities
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: click>=8.0
Requires-Dist: rich>=13.0
Dynamic: license-file

# migs - Google Cloud MIG CLI Tool

A command-line tool that wraps the gcloud CLI to provide an easier experience for managing Google Cloud Managed Instance Groups.

## Features

- List MIGs in your project
- Spin up/down VMs with custom names
- Track your personal VMs
- Automatic SSH config management for VS Code Remote Explorer
- Easy file/directory uploads

## Installation

```bash
pip install -e .
```

## Prerequisites

- Python 3.8+
- gcloud CLI installed and authenticated (`gcloud auth login`)
- SSH keys configured for Google Compute Engine

## Usage

### List all MIGs
```bash
migs list
```

### Spin up a VM
```bash
migs up my-mig --name my-dev-vm
migs up my-mig --name my-dev-vm --async  # Don't wait for creation
migs up my-mig --name my-dev-vm -d 2h  # Auto-delete after 2 hours
migs up my-mig --name my-dev-vm --duration=2h  # Alternative syntax
```

### List your VMs
```bash
migs vms
```

### Sync VM state
```bash
migs sync  # Sync local VM list with GCP state
migs sync --discover  # Also discover and claim untracked VMs
```

### Check VM connectivity
```bash
migs check my-dev-vm  # Test SSH connectivity
```

### SSH into a VM
```bash
migs ssh my-dev-vm
migs ssh my-dev-vm -- tmux attach  # Pass additional SSH arguments
```

### Run scripts
```bash
migs run my-dev-vm ./setup.sh  # Runs in tmux session
migs run my-dev-vm ./deploy.sh --session deploy  # Custom session name
migs run my-dev-vm ./script.sh arg1 arg2  # Pass arguments to script
```

### Environment Variables (.env files)
Both `ssh` and `run` commands automatically detect and use `.env` files from your current directory:

```bash
# If .env exists in current directory, it will be uploaded and sourced
migs ssh my-dev-vm  # Variables from .env available in shell
migs run my-dev-vm ./app.sh  # Script runs with .env variables
```

The `.env` file is uploaded to `/tmp/.env` on the VM and sourced using `set -a; source /tmp/.env; set +a` to export all variables.

### Upload files
```bash
migs upload my-dev-vm ./myfile.txt
migs upload my-dev-vm ./mydir/ /home/user/
```

### Download files
```bash
migs download my-dev-vm /remote/file.txt
migs download my-dev-vm /remote/dir/ ./local/
```

### Spin down a VM
```bash
migs down my-dev-vm
```

## SSH Config

The tool automatically updates your `~/.ssh/config` file with entries for your VMs, making them accessible in VS Code Remote Explorer.

# Release Instructions
- Test
```bash
python3 -m build
twine upload --repository testpypi dist/* # may take a second to index
pip uninstall migs
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple migs
```
- Deploy
```bash
twine upload dist/*
git tag v0.1.x
git push origin v0.1.x
```
