toast-cli 3.0.0.dev0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- toast_cli-3.0.0.dev0/.mergify.yml +14 -0
- toast_cli-3.0.0.dev0/ARCHITECTURE.md +208 -0
- toast_cli-3.0.0.dev0/CNAME +1 -0
- toast_cli-3.0.0.dev0/LICENSE +674 -0
- toast_cli-3.0.0.dev0/MANIFEST.in +7 -0
- toast_cli-3.0.0.dev0/PKG-INFO +161 -0
- toast_cli-3.0.0.dev0/README.md +127 -0
- toast_cli-3.0.0.dev0/VERSION +1 -0
- toast_cli-3.0.0.dev0/favicon.ico +0 -0
- toast_cli-3.0.0.dev0/pyproject.toml +3 -0
- toast_cli-3.0.0.dev0/setup.cfg +37 -0
- toast_cli-3.0.0.dev0/setup.py +48 -0
- toast_cli-3.0.0.dev0/toast/__init__.py +83 -0
- toast_cli-3.0.0.dev0/toast/__main__.py +6 -0
- toast_cli-3.0.0.dev0/toast/helpers.py +38 -0
- toast_cli-3.0.0.dev0/toast/plugins/__init__.py +1 -0
- toast_cli-3.0.0.dev0/toast/plugins/am_plugin.py +23 -0
- toast_cli-3.0.0.dev0/toast/plugins/base_plugin.py +31 -0
- toast_cli-3.0.0.dev0/toast/plugins/cdw_plugin.py +33 -0
- toast_cli-3.0.0.dev0/toast/plugins/ctx_plugin.py +62 -0
- toast_cli-3.0.0.dev0/toast/plugins/env_plugin.py +212 -0
- toast_cli-3.0.0.dev0/toast/plugins/git_plugin.py +92 -0
- toast_cli-3.0.0.dev0/toast/plugins/region_plugin.py +32 -0
- toast_cli-3.0.0.dev0/toast/plugins/ssm_plugin.py +14 -0
- toast_cli-3.0.0.dev0/toast/plugins/update_plugin.py +14 -0
- toast_cli-3.0.0.dev0/toast/plugins/utils.py +12 -0
- toast_cli-3.0.0.dev0/toast_cli.egg-info/PKG-INFO +161 -0
- toast_cli-3.0.0.dev0/toast_cli.egg-info/SOURCES.txt +32 -0
- toast_cli-3.0.0.dev0/toast_cli.egg-info/dependency_links.txt +1 -0
- toast_cli-3.0.0.dev0/toast_cli.egg-info/entry_points.txt +2 -0
- toast_cli-3.0.0.dev0/toast_cli.egg-info/not-zip-safe +1 -0
- toast_cli-3.0.0.dev0/toast_cli.egg-info/requires.txt +2 -0
- toast_cli-3.0.0.dev0/toast_cli.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
pull_request_rules:
|
|
2
|
+
- name: automatic merge
|
|
3
|
+
conditions:
|
|
4
|
+
- base=main
|
|
5
|
+
- "#approved-reviews-by>=1"
|
|
6
|
+
# - "status-success=ci/circleci"
|
|
7
|
+
actions:
|
|
8
|
+
merge:
|
|
9
|
+
method: merge
|
|
10
|
+
# method: rebase
|
|
11
|
+
# rebase_fallback: merge
|
|
12
|
+
# strict: smart
|
|
13
|
+
dismiss_reviews: {}
|
|
14
|
+
delete_head_branch: {}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# Toast.sh Architecture
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Toast.sh is a Python-based CLI tool that provides various utility commands for AWS and Kubernetes management. The architecture follows a plugin-based design pattern, allowing for easy extension of functionality through the addition of new plugins.
|
|
6
|
+
|
|
7
|
+
## Package Structure
|
|
8
|
+
|
|
9
|
+
The project is organized as a Python package with the following structure:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
toast-cli/
|
|
13
|
+
├── setup.py # Package setup script
|
|
14
|
+
├── setup.cfg # Package configuration
|
|
15
|
+
├── pyproject.toml # Build system requirements
|
|
16
|
+
├── MANIFEST.in # Additional files to include in the package
|
|
17
|
+
├── VERSION # Version information
|
|
18
|
+
├── README.md # Project documentation
|
|
19
|
+
├── ARCHITECTURE.md # Architecture documentation
|
|
20
|
+
├── LICENSE # License information
|
|
21
|
+
└── toast/ # Main package
|
|
22
|
+
├── __init__.py # Package initialization and CLI entry point
|
|
23
|
+
└── plugins/ # Plugin modules
|
|
24
|
+
├── __init__.py
|
|
25
|
+
├── base_plugin.py
|
|
26
|
+
├── am_plugin.py
|
|
27
|
+
├── cdw_plugin.py
|
|
28
|
+
├── ctx_plugin.py
|
|
29
|
+
├── env_plugin.py
|
|
30
|
+
├── git_plugin.py
|
|
31
|
+
├── region_plugin.py
|
|
32
|
+
├── ssm_plugin.py
|
|
33
|
+
├── update_plugin.py
|
|
34
|
+
└── utils.py
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Components
|
|
38
|
+
|
|
39
|
+
### Main Application (toast/__init__.py)
|
|
40
|
+
|
|
41
|
+
The main entry point of the application is responsible for:
|
|
42
|
+
- Dynamically discovering and loading plugins from the `toast.plugins` package
|
|
43
|
+
- Registering plugin commands with the CLI interface using Click
|
|
44
|
+
- Running the CLI with all discovered commands
|
|
45
|
+
|
|
46
|
+
### Plugin System
|
|
47
|
+
|
|
48
|
+
The plugin system is based on Python's `importlib` and `pkgutil` modules, which enable dynamic loading of modules at runtime. This allows the application to be extended without modifying the core code.
|
|
49
|
+
|
|
50
|
+
#### Core Plugin Components
|
|
51
|
+
|
|
52
|
+
1. **BasePlugin (`plugins/base_plugin.py`)**
|
|
53
|
+
- Abstract base class that all plugins must extend
|
|
54
|
+
- Defines the interface for plugins
|
|
55
|
+
- Provides registration mechanism for adding commands to the CLI
|
|
56
|
+
|
|
57
|
+
2. **Utilities (`plugins/utils.py`)**
|
|
58
|
+
- Common utility functions used by multiple plugins
|
|
59
|
+
- Examples include the `select_from_list` function for interactive selection
|
|
60
|
+
|
|
61
|
+
### Plugin Structure
|
|
62
|
+
|
|
63
|
+
Each plugin follows a standard structure:
|
|
64
|
+
- Inherits from `BasePlugin`
|
|
65
|
+
- Defines a unique `name` and `help` text
|
|
66
|
+
- Implements `execute()` method containing the command logic
|
|
67
|
+
- Optionally overrides `get_arguments()` to define custom command arguments
|
|
68
|
+
|
|
69
|
+
### Plugin Loading Process
|
|
70
|
+
|
|
71
|
+
1. The application scans the `plugins` directory for Python modules
|
|
72
|
+
2. Each module is imported and examined for classes that extend `BasePlugin`
|
|
73
|
+
3. Valid plugin classes are instantiated and registered with the CLI
|
|
74
|
+
4. Click handles argument parsing and command execution
|
|
75
|
+
|
|
76
|
+
## Current Plugins
|
|
77
|
+
|
|
78
|
+
| Plugin | Command | Description |
|
|
79
|
+
|--------|---------|-------------|
|
|
80
|
+
| AmPlugin | am | Show AWS caller identity |
|
|
81
|
+
| CdwPlugin | cdw | Navigate to workspace directories |
|
|
82
|
+
| CtxPlugin | ctx | Manage Kubernetes contexts |
|
|
83
|
+
| EnvPlugin | env | Set environment with AWS profile |
|
|
84
|
+
| GitPlugin | git | Manage Git repositories |
|
|
85
|
+
| RegionPlugin | region | Set AWS region |
|
|
86
|
+
| SsmPlugin | ssm | Run AWS SSM commands |
|
|
87
|
+
| UpdatePlugin | update | Update CLI tool |
|
|
88
|
+
|
|
89
|
+
### Plugin Details
|
|
90
|
+
|
|
91
|
+
#### EnvPlugin (env command)
|
|
92
|
+
|
|
93
|
+
The `env` command handles AWS environment profile management:
|
|
94
|
+
|
|
95
|
+
1. **Environment Path Discovery**:
|
|
96
|
+
- Looks for AWS_ENV_PATH in the .env file in the current directory
|
|
97
|
+
- If not found, creates a path at ~/workspace/github.com/{username}/keys/env
|
|
98
|
+
- Uses whoami to get the default username, but allows customization
|
|
99
|
+
|
|
100
|
+
2. **Profile Management**:
|
|
101
|
+
- Lists and allows selection of profiles from the environment path
|
|
102
|
+
- Loads environment variables from the selected profile file
|
|
103
|
+
- Sets AWS_PROFILE environment variable
|
|
104
|
+
|
|
105
|
+
3. **Authentication Verification**:
|
|
106
|
+
- Verifies credentials by calling AWS STS get-caller-identity
|
|
107
|
+
- Uses jq to provide colorized JSON output of the AWS identity information
|
|
108
|
+
- Displays AWS region if available
|
|
109
|
+
|
|
110
|
+
4. **File Structure**:
|
|
111
|
+
- Environment profiles are stored as files in the env directory
|
|
112
|
+
- Each file contains key=value pairs for environment variables
|
|
113
|
+
|
|
114
|
+
#### GitPlugin (git command)
|
|
115
|
+
|
|
116
|
+
The `git` command handles Git repository operations:
|
|
117
|
+
|
|
118
|
+
1. **Repository Path Validation**:
|
|
119
|
+
- Validates that the current directory is in the ~/workspace/github.com/{username} format
|
|
120
|
+
- Extracts username from the current path for repository operations
|
|
121
|
+
|
|
122
|
+
2. **Repository Cloning**:
|
|
123
|
+
- Clones repositories from the user's GitHub account using the username extracted from path
|
|
124
|
+
- Supports cloning to a specified target directory name (optional)
|
|
125
|
+
- Format: `toast git repo_name clone` (기본) 또는 `toast git repo_name clone --target target_name` (대상 디렉토리 지정)
|
|
126
|
+
|
|
127
|
+
3. **Repository Removal**:
|
|
128
|
+
- Safely removes repository directories with confirmation prompt
|
|
129
|
+
- Format: `toast git repo_name rm`
|
|
130
|
+
|
|
131
|
+
4. **Path Management**:
|
|
132
|
+
- Automatically constructs GitHub repository URLs based on extracted username
|
|
133
|
+
- Manages repository paths within the workspace directory structure
|
|
134
|
+
|
|
135
|
+
## Dependencies
|
|
136
|
+
|
|
137
|
+
The plugin system has the following external dependencies:
|
|
138
|
+
- Click: Command-line interface creation
|
|
139
|
+
- Python-Dotenv: Environment variable management from .env files
|
|
140
|
+
|
|
141
|
+
## Adding New Plugins
|
|
142
|
+
|
|
143
|
+
To add a new plugin:
|
|
144
|
+
1. Create a new Python file in the `plugins` directory
|
|
145
|
+
2. Define a class that extends `BasePlugin`
|
|
146
|
+
3. Implement the required methods (`execute` and optionally `get_arguments`)
|
|
147
|
+
4. Set the `name` and `help` class variables
|
|
148
|
+
|
|
149
|
+
The plugin will be automatically discovered and loaded when the application starts.
|
|
150
|
+
|
|
151
|
+
## Benefits of the Plugin Architecture
|
|
152
|
+
|
|
153
|
+
- **Modularity**: Each command is isolated in its own module
|
|
154
|
+
- **Extensibility**: New commands can be added without modifying existing code
|
|
155
|
+
- **Maintainability**: Code is organized into logical components
|
|
156
|
+
- **Testability**: Plugins can be tested independently
|
|
157
|
+
|
|
158
|
+
## Packaging and Distribution
|
|
159
|
+
|
|
160
|
+
The project is packaged using standard Python packaging tools. The following files enable packaging and distribution:
|
|
161
|
+
|
|
162
|
+
1. **setup.py**: The main setup script that defines package metadata and dependencies
|
|
163
|
+
2. **setup.cfg**: Configuration file for package metadata and entry points
|
|
164
|
+
3. **pyproject.toml**: Defines build system requirements
|
|
165
|
+
4. **MANIFEST.in**: Specifies additional files to include in the source distribution
|
|
166
|
+
|
|
167
|
+
### Installation Methods
|
|
168
|
+
|
|
169
|
+
The package can be installed using pip:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
# Install from PyPI (once published)
|
|
173
|
+
pip install toast-cli
|
|
174
|
+
|
|
175
|
+
# Install from local directory in development mode
|
|
176
|
+
pip install -e .
|
|
177
|
+
|
|
178
|
+
# Install from GitHub
|
|
179
|
+
pip install git+https://github.com/opspresso/toast.sh.git
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Building Distribution Packages
|
|
183
|
+
|
|
184
|
+
To build distribution packages:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
# Install build requirements
|
|
188
|
+
pip install build
|
|
189
|
+
|
|
190
|
+
# Build source and wheel distributions
|
|
191
|
+
python -m build
|
|
192
|
+
|
|
193
|
+
# This will create:
|
|
194
|
+
# - dist/toast-cli-X.Y.Z.tar.gz (source distribution)
|
|
195
|
+
# - dist/toast_cli-X.Y.Z-py3-none-any.whl (wheel distribution)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Publishing to PyPI
|
|
199
|
+
|
|
200
|
+
To publish the package to PyPI:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
# Install twine
|
|
204
|
+
pip install twine
|
|
205
|
+
|
|
206
|
+
# Upload to PyPI
|
|
207
|
+
twine upload dist/*
|
|
208
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
toast.sh
|