kdebug 0.2.0__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.
@@ -0,0 +1,10 @@
1
+ version: 2
2
+
3
+ updates:
4
+ - package-ecosystem: "github-actions"
5
+ directory: "/"
6
+ schedule:
7
+ interval: "weekly"
8
+ open-pull-requests-limit: 10
9
+ commit-message:
10
+ prefix: "chore(deps)"
@@ -0,0 +1,40 @@
1
+ # Uses PyPI Trusted Publisher (OIDC) - no token required
2
+ # Configure at: https://pypi.org/manage/project/kdebug/settings/publishing/
3
+
4
+ name: Publish to PyPI
5
+
6
+ on:
7
+ workflow_call:
8
+ inputs:
9
+ ref:
10
+ description: 'Git reference to checkout'
11
+ required: false
12
+ type: string
13
+ release:
14
+ types: [published]
15
+ workflow_dispatch:
16
+
17
+ permissions:
18
+ id-token: write
19
+ contents: read
20
+
21
+ jobs:
22
+ publish:
23
+ runs-on: ubuntu-latest
24
+ environment: pypi
25
+ steps:
26
+ - name: Check out
27
+ uses: actions/checkout@v4
28
+ with:
29
+ ref: ${{ inputs.ref || github.ref }}
30
+
31
+ - name: Install uv
32
+ uses: astral-sh/setup-uv@v5
33
+ with:
34
+ version: "latest"
35
+
36
+ - name: Build package
37
+ run: uv build
38
+
39
+ - name: Publish package
40
+ run: uv publish --trusted-publishing always
@@ -0,0 +1,87 @@
1
+ name: Create Release
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ release_type:
7
+ description: 'Release type'
8
+ required: true
9
+ default: 'patch'
10
+ type: choice
11
+ options:
12
+ - patch
13
+ - minor
14
+ - major
15
+
16
+ permissions:
17
+ contents: write
18
+ id-token: write
19
+
20
+ jobs:
21
+ release:
22
+ runs-on: ubuntu-latest
23
+ outputs:
24
+ version: ${{ steps.new.outputs.version }}
25
+ steps:
26
+ - uses: actions/checkout@v4
27
+ with:
28
+ fetch-depth: 0
29
+
30
+ - name: Configure Git
31
+ run: |
32
+ git config user.name "github-actions[bot]"
33
+ git config user.email "github-actions[bot]@users.noreply.github.com"
34
+
35
+ - name: Get current version
36
+ id: current
37
+ run: |
38
+ VERSION=$(grep -oP '^version = "\K[^"]+' pyproject.toml)
39
+ echo "version=$VERSION" >> $GITHUB_OUTPUT
40
+
41
+ - name: Calculate new version
42
+ id: new
43
+ run: |
44
+ IFS='.' read -r major minor patch <<< "${{ steps.current.outputs.version }}"
45
+ case "${{ inputs.release_type }}" in
46
+ major) major=$((major + 1)); minor=0; patch=0 ;;
47
+ minor) minor=$((minor + 1)); patch=0 ;;
48
+ patch) patch=$((patch + 1)) ;;
49
+ esac
50
+ echo "version=${major}.${minor}.${patch}" >> $GITHUB_OUTPUT
51
+
52
+ - name: Update version in pyproject.toml
53
+ run: |
54
+ sed -i 's/^version = "[^"]*"/version = "${{ steps.new.outputs.version }}"/' pyproject.toml
55
+
56
+ - name: Commit and tag
57
+ run: |
58
+ git add pyproject.toml
59
+ git commit -m "Release v${{ steps.new.outputs.version }}"
60
+ git tag "v${{ steps.new.outputs.version }}"
61
+
62
+ - name: Push changes
63
+ run: |
64
+ git push origin HEAD:${{ github.ref_name }}
65
+ git push --tags
66
+
67
+ - name: Create GitHub Release
68
+ env:
69
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70
+ run: |
71
+ gh release create "v${{ steps.new.outputs.version }}" \
72
+ --generate-notes \
73
+ --latest
74
+
75
+ update-homebrew:
76
+ needs: release
77
+ uses: ./.github/workflows/update-homebrew.yml
78
+ with:
79
+ version: v${{ needs.release.outputs.version }}
80
+ secrets: inherit
81
+
82
+ publish-pypi:
83
+ needs: release
84
+ uses: ./.github/workflows/pypi-publish.yml
85
+ with:
86
+ ref: v${{ needs.release.outputs.version }}
87
+ secrets: inherit
@@ -0,0 +1,50 @@
1
+ name: Update Homebrew Tap
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch:
7
+ workflow_call:
8
+ inputs:
9
+ version:
10
+ description: 'Version tag (e.g., v1.0.0)'
11
+ required: false
12
+ type: string
13
+
14
+ jobs:
15
+ update-homebrew-tap:
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ - name: Get release info
19
+ id: release-info
20
+ run: |
21
+ # Use input version if provided, otherwise extract from GITHUB_REF
22
+ if [[ -n "${{ inputs.version }}" ]]; then
23
+ VERSION="${{ inputs.version }}"
24
+ else
25
+ VERSION=${GITHUB_REF#refs/tags/}
26
+ fi
27
+ echo "version=$VERSION" >> $GITHUB_OUTPUT
28
+ echo "Release version: $VERSION"
29
+
30
+ - name: Trigger Homebrew tap update
31
+ run: |
32
+ curl -L \
33
+ -X POST \
34
+ -H "Accept: application/vnd.github+json" \
35
+ -H "Authorization: Bearer ${{ secrets.HOMEBREW_TAP_TOKEN }}" \
36
+ -H "X-GitHub-Api-Version: 2022-11-28" \
37
+ https://api.github.com/repos/jessegoodier/homebrew-kdebug/dispatches \
38
+ -d '{
39
+ "event_type": "update-homebrew-formula",
40
+ "client_payload": {
41
+ "version": "${{ steps.release-info.outputs.version }}",
42
+ "repository": "${{ github.repository }}"
43
+ }
44
+ }'
45
+
46
+ - name: Create workflow summary
47
+ run: |
48
+ echo "🍺 Triggered Homebrew tap update for kdebug version ${{ steps.release-info.outputs.version }}" >> $GITHUB_STEP_SUMMARY
49
+ echo "" >> $GITHUB_STEP_SUMMARY
50
+ echo "The Homebrew formula will be updated automatically in the [homebrew-kdebug](https://github.com/jessegoodier/homebrew-kdebug) repository." >> $GITHUB_STEP_SUMMARY
@@ -0,0 +1,216 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ # Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ # poetry.lock
109
+ # poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ # pdm.lock
116
+ # pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ # pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # Redis
135
+ *.rdb
136
+ *.aof
137
+ *.pid
138
+
139
+ # RabbitMQ
140
+ mnesia/
141
+ rabbitmq/
142
+ rabbitmq-data/
143
+
144
+ # ActiveMQ
145
+ activemq-data/
146
+
147
+ # SageMath parsed files
148
+ *.sage.py
149
+
150
+ # Environments
151
+ .env
152
+ .envrc
153
+ .venv
154
+ env/
155
+ venv/
156
+ ENV/
157
+ env.bak/
158
+ venv.bak/
159
+
160
+ # Spyder project settings
161
+ .spyderproject
162
+ .spyproject
163
+
164
+ # Rope project settings
165
+ .ropeproject
166
+
167
+ # mkdocs documentation
168
+ /site
169
+
170
+ # mypy
171
+ .mypy_cache/
172
+ .dmypy.json
173
+ dmypy.json
174
+
175
+ # Pyre type checker
176
+ .pyre/
177
+
178
+ # pytype static type analyzer
179
+ .pytype/
180
+
181
+ # Cython debug symbols
182
+ cython_debug/
183
+
184
+ # PyCharm
185
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
186
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
187
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
188
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
189
+ # .idea/
190
+
191
+ # Abstra
192
+ # Abstra is an AI-powered process automation framework.
193
+ # Ignore directories containing user credentials, local state, and settings.
194
+ # Learn more at https://abstra.io/docs
195
+ .abstra/
196
+
197
+ # Visual Studio Code
198
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
199
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
200
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
201
+ # you could uncomment the following to ignore the entire vscode folder
202
+ # .vscode/
203
+
204
+ # Ruff stuff:
205
+ .ruff_cache/
206
+
207
+ # PyPI configuration file
208
+ .pypirc
209
+
210
+ # Marimo
211
+ marimo/_static/
212
+ marimo/_lsp/
213
+ __marimo__/
214
+
215
+ # Streamlit
216
+ .streamlit/secrets.toml
kdebug-0.2.0/AGENTS.md ADDED
@@ -0,0 +1,141 @@
1
+ # AGENTS.md - AI Assistant Guide
2
+
3
+ This file helps AI coding assistants understand the kdebug project.
4
+
5
+ ## Project Overview
6
+
7
+ kdebug is a Python CLI tool for launching ephemeral debug containers in Kubernetes pods. It provides interactive shell access, backup capabilities, and a TUI for pod selection.
8
+
9
+ ## Project Structure
10
+
11
+ ```
12
+ kdebug/
13
+ ├── pyproject.toml # Package metadata and build config (version source of truth)
14
+ ├── src/
15
+ │ └── kdebug/
16
+ │ ├── __init__.py # Package init with __version__ from importlib.metadata
17
+ │ └── cli.py # Main CLI code
18
+ ├── completions/
19
+ │ ├── kdebug.bash # Bash completion script (generated)
20
+ │ └── _kdebug # Zsh completion script (generated)
21
+ ├── README.md # User documentation
22
+ ├── AGENTS.md # This file
23
+ └── .github/
24
+ └── workflows/
25
+ └── release.yml # Release automation (updates pyproject.toml)
26
+ ```
27
+
28
+ ## Key Architecture
29
+
30
+ - **Python package**: Installable via `uv tool install kdebug` or `pip install .`
31
+ - **Entry point**: `kdebug` command maps to `kdebug.cli:main`
32
+ - **Version**: Single source of truth in `pyproject.toml`, accessed via `importlib.metadata`
33
+ - **No external dependencies**: Uses Python stdlib only
34
+ - **Completion scripts are generated**: The functions `generate_bash_completion()` and `generate_zsh_completion()` in `src/kdebug/cli.py` produce the completion files
35
+ - **Global state pattern**: Module-level variables (`DEBUG_MODE`, `KUBECTL_CONTEXT`, `KUBECTL_KUBECONFIG`) are set after argument parsing
36
+
37
+ ## Making Changes
38
+
39
+ ### Adding a new CLI argument
40
+
41
+ 1. Add the argument to the appropriate `parser.add_argument_group()` in `main()`
42
+ 2. If it affects kubectl commands, update the relevant helper function or `kubectl_base_cmd()`
43
+ 3. Update `generate_bash_completion()` - add to `opts` list and add completion case if needed
44
+ 4. Update `generate_zsh_completion()` - add to `args` array with appropriate completer
45
+ 5. Regenerate completion files (see below)
46
+ 6. Update README.md if user-facing
47
+
48
+ ### Modifying kubectl commands
49
+
50
+ All kubectl commands should use `kubectl_base_cmd()` to ensure `--context` and `--kubeconfig` are passed through:
51
+
52
+ ```python
53
+ cmd = f"{kubectl_base_cmd()} get pods -n {namespace} -o json"
54
+ ```
55
+
56
+ ### Regenerating completion files
57
+
58
+ After modifying the completion generators:
59
+
60
+ ```bash
61
+ # Install package in development mode first
62
+ uv pip install -e .
63
+
64
+ # Then regenerate completions
65
+ kdebug --completions bash > completions/kdebug.bash
66
+ kdebug --completions zsh > completions/_kdebug
67
+ ```
68
+
69
+ ## Testing
70
+
71
+ ### Manual testing
72
+
73
+ ```bash
74
+ # Install in development mode
75
+ uv pip install -e .
76
+
77
+ # Verify help output
78
+ kdebug --help
79
+
80
+ # Verify version
81
+ kdebug --version
82
+
83
+ # Test with debug mode to see kubectl commands
84
+ kdebug --debug -n <namespace>
85
+
86
+ # Test argument combinations
87
+ kdebug --context <ctx> --kubeconfig <path> -n <ns> --pod <pod>
88
+ ```
89
+
90
+ ### Syntax checks
91
+
92
+ ```bash
93
+ # Python syntax
94
+ python3 -m py_compile src/kdebug/cli.py
95
+
96
+ # Bash completion syntax
97
+ bash -n completions/kdebug.bash
98
+
99
+ # Zsh completion syntax
100
+ zsh -n completions/_kdebug
101
+ ```
102
+
103
+ ### Testing completions
104
+
105
+ ```bash
106
+ # Bash
107
+ source <(kdebug --completions bash)
108
+ kdebug --<TAB>
109
+
110
+ # Zsh
111
+ source <(kdebug --completions zsh)
112
+ kdebug --<TAB>
113
+ ```
114
+
115
+ ## Code Conventions
116
+
117
+ - Use `colorize()` for colored output
118
+ - Use `run_command()` for executing shell commands
119
+ - Use `print_debug_command()` to show commands when `--debug` is enabled
120
+ - Error messages go to stderr with `file=sys.stderr`
121
+ - Success indicators use green checkmarks: `{colorize('✓', Colors.GREEN)}`
122
+ - Error indicators use red X: `{colorize('✗', Colors.RED)}`
123
+
124
+ ## Dependencies
125
+
126
+ - Python 3.8+ (for `importlib.metadata`)
127
+ - kubectl (must be in PATH and configured)
128
+ - No pip packages required
129
+
130
+ ## Installation
131
+
132
+ ```bash
133
+ # Via uv (recommended)
134
+ uv tool install kdebug
135
+
136
+ # Via pip
137
+ pip install .
138
+
139
+ # Development mode
140
+ uv pip install -e .
141
+ ```