kctl-cf 0.3.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.
Files changed (70) hide show
  1. kctl_cf-0.3.0/.gitignore +33 -0
  2. kctl_cf-0.3.0/PKG-INFO +18 -0
  3. kctl_cf-0.3.0/README.md +367 -0
  4. kctl_cf-0.3.0/deploy/Dockerfile +6 -0
  5. kctl_cf-0.3.0/deploy/docker-compose.prod.yml +38 -0
  6. kctl_cf-0.3.0/pyproject.toml +46 -0
  7. kctl_cf-0.3.0/skills/cloudflare-admin/SKILL.md +245 -0
  8. kctl_cf-0.3.0/src/kctl_cf/__init__.py +3 -0
  9. kctl_cf-0.3.0/src/kctl_cf/__main__.py +5 -0
  10. kctl_cf-0.3.0/src/kctl_cf/cli.py +189 -0
  11. kctl_cf-0.3.0/src/kctl_cf/commands/__init__.py +0 -0
  12. kctl_cf-0.3.0/src/kctl_cf/commands/access.py +447 -0
  13. kctl_cf-0.3.0/src/kctl_cf/commands/aliases.py +107 -0
  14. kctl_cf-0.3.0/src/kctl_cf/commands/analytics.py +194 -0
  15. kctl_cf-0.3.0/src/kctl_cf/commands/argo.py +97 -0
  16. kctl_cf-0.3.0/src/kctl_cf/commands/cache.py +77 -0
  17. kctl_cf-0.3.0/src/kctl_cf/commands/config_cmd.py +379 -0
  18. kctl_cf-0.3.0/src/kctl_cf/commands/custom_hostnames.py +148 -0
  19. kctl_cf-0.3.0/src/kctl_cf/commands/doctor_cmd.py +82 -0
  20. kctl_cf-0.3.0/src/kctl_cf/commands/email_routing.py +233 -0
  21. kctl_cf-0.3.0/src/kctl_cf/commands/export.py +400 -0
  22. kctl_cf-0.3.0/src/kctl_cf/commands/health.py +508 -0
  23. kctl_cf-0.3.0/src/kctl_cf/commands/load_balancers.py +298 -0
  24. kctl_cf-0.3.0/src/kctl_cf/commands/page_rules.py +169 -0
  25. kctl_cf-0.3.0/src/kctl_cf/commands/pages.py +301 -0
  26. kctl_cf-0.3.0/src/kctl_cf/commands/r2.py +171 -0
  27. kctl_cf-0.3.0/src/kctl_cf/commands/records.py +256 -0
  28. kctl_cf-0.3.0/src/kctl_cf/commands/redirects.py +183 -0
  29. kctl_cf-0.3.0/src/kctl_cf/commands/selftest.py +59 -0
  30. kctl_cf-0.3.0/src/kctl_cf/commands/skill_cmd.py +76 -0
  31. kctl_cf-0.3.0/src/kctl_cf/commands/spectrum.py +178 -0
  32. kctl_cf-0.3.0/src/kctl_cf/commands/speed.py +198 -0
  33. kctl_cf-0.3.0/src/kctl_cf/commands/ssl.py +205 -0
  34. kctl_cf-0.3.0/src/kctl_cf/commands/status.py +162 -0
  35. kctl_cf-0.3.0/src/kctl_cf/commands/terraform.py +107 -0
  36. kctl_cf-0.3.0/src/kctl_cf/commands/tokens.py +287 -0
  37. kctl_cf-0.3.0/src/kctl_cf/commands/tunnels.py +211 -0
  38. kctl_cf-0.3.0/src/kctl_cf/commands/waf.py +329 -0
  39. kctl_cf-0.3.0/src/kctl_cf/commands/waiting_rooms.py +178 -0
  40. kctl_cf-0.3.0/src/kctl_cf/commands/workers.py +381 -0
  41. kctl_cf-0.3.0/src/kctl_cf/commands/zones.py +214 -0
  42. kctl_cf-0.3.0/src/kctl_cf/core/__init__.py +0 -0
  43. kctl_cf-0.3.0/src/kctl_cf/core/callbacks.py +28 -0
  44. kctl_cf-0.3.0/src/kctl_cf/core/client.py +50 -0
  45. kctl_cf-0.3.0/src/kctl_cf/core/config.py +144 -0
  46. kctl_cf-0.3.0/src/kctl_cf/core/exceptions.py +25 -0
  47. kctl_cf-0.3.0/src/kctl_cf/core/notify.py +113 -0
  48. kctl_cf-0.3.0/src/kctl_cf/core/output.py +5 -0
  49. kctl_cf-0.3.0/src/kctl_cf/core/plugins.py +57 -0
  50. kctl_cf-0.3.0/src/kctl_cf/core/utils.py +75 -0
  51. kctl_cf-0.3.0/terraform/caching.tf +61 -0
  52. kctl_cf-0.3.0/terraform/email_routing.tf +47 -0
  53. kctl_cf-0.3.0/terraform/firewall.tf +59 -0
  54. kctl_cf-0.3.0/terraform/main.tf +26 -0
  55. kctl_cf-0.3.0/terraform/outputs.tf +109 -0
  56. kctl_cf-0.3.0/terraform/r2.tf +9 -0
  57. kctl_cf-0.3.0/terraform/records.tf +18 -0
  58. kctl_cf-0.3.0/terraform/redirects.tf +52 -0
  59. kctl_cf-0.3.0/terraform/ssl.tf +22 -0
  60. kctl_cf-0.3.0/terraform/terraform.tfvars.example +221 -0
  61. kctl_cf-0.3.0/terraform/tunnels.tf +49 -0
  62. kctl_cf-0.3.0/terraform/variables.tf +260 -0
  63. kctl_cf-0.3.0/terraform/workers.tf +45 -0
  64. kctl_cf-0.3.0/terraform/zones.tf +55 -0
  65. kctl_cf-0.3.0/tests/__init__.py +0 -0
  66. kctl_cf-0.3.0/tests/conftest.py +94 -0
  67. kctl_cf-0.3.0/tests/test_commands.py +906 -0
  68. kctl_cf-0.3.0/tests/test_output.py +299 -0
  69. kctl_cf-0.3.0/tests/test_smoke.py +105 -0
  70. kctl_cf-0.3.0/tests/test_tokens.py +348 -0
@@ -0,0 +1,33 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ *.egg
6
+ dist/
7
+ build/
8
+ .eggs/
9
+
10
+ # Virtual environments
11
+ .venv/
12
+ venv/
13
+
14
+ # IDE
15
+ .idea/
16
+ .vscode/
17
+ *.swp
18
+ *.swo
19
+
20
+ # Testing
21
+ .pytest_cache/
22
+ .coverage
23
+ htmlcov/
24
+ .mypy_cache/
25
+ .ruff_cache/
26
+
27
+ # OS
28
+ .DS_Store
29
+ Thumbs.db
30
+
31
+ # Environment
32
+ .env
33
+ .env.local
kctl_cf-0.3.0/PKG-INFO ADDED
@@ -0,0 +1,18 @@
1
+ Metadata-Version: 2.4
2
+ Name: kctl-cf
3
+ Version: 0.3.0
4
+ Summary: Kodemeio Cloudflare CLI — manage Cloudflare infrastructure
5
+ Requires-Python: >=3.12
6
+ Requires-Dist: httpx>=0.28.0
7
+ Requires-Dist: kctl-lib>=0.4.0
8
+ Requires-Dist: pydantic>=2.10.0
9
+ Requires-Dist: pyyaml>=6.0.2
10
+ Requires-Dist: rich>=13.9.0
11
+ Requires-Dist: typer>=0.15.0
12
+ Provides-Extra: dev
13
+ Requires-Dist: mypy>=1.14.0; extra == 'dev'
14
+ Requires-Dist: pytest-cov>=6.0.0; extra == 'dev'
15
+ Requires-Dist: pytest-httpx>=0.35.0; extra == 'dev'
16
+ Requires-Dist: pytest>=8.3.0; extra == 'dev'
17
+ Requires-Dist: ruff>=0.9.0; extra == 'dev'
18
+ Requires-Dist: types-pyyaml>=6.0.0; extra == 'dev'
@@ -0,0 +1,367 @@
1
+ # kctl-cf
2
+
3
+ Kodemeio Cloudflare CLI -- manage DNS, tunnels, WAF, cache, Workers, R2, email routing, and Zero Trust Access across all zones and accounts.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ uv tool install kctl-cf
9
+ ```
10
+
11
+ To upgrade after code changes:
12
+
13
+ ```bash
14
+ uv tool install --force --reinstall kctl-cf
15
+ ```
16
+
17
+ ## Quick Start
18
+
19
+ ```bash
20
+ # Configure connection (interactive)
21
+ kctl-cf config init
22
+
23
+ # Verify connectivity
24
+ kctl-cf health check
25
+
26
+ # List all zones in the account
27
+ kctl-cf zones list
28
+
29
+ # List DNS records for a zone
30
+ kctl-cf records list --zone example.com
31
+
32
+ # Purge cache for a zone
33
+ kctl-cf cache purge-all --zone example.com
34
+
35
+ # Check SSL/TLS status
36
+ kctl-cf ssl status --zone example.com
37
+
38
+ # List Cloudflare Tunnels
39
+ kctl-cf tunnels list
40
+
41
+ # Account-wide status overview
42
+ kctl-cf status overview
43
+ ```
44
+
45
+ ## Command Groups
46
+
47
+ | Group | Commands | Description |
48
+ |---------------------|----------|-----------------------------------------------------------------|
49
+ | `access` | 17 | Manage Cloudflare Zero Trust Access (apps, policies, groups) |
50
+ | `analytics` | 2 | Zone analytics and traffic reports |
51
+ | `argo` | 3 | Manage Argo Smart Routing and Tiered Caching |
52
+ | `cache` | 3 | Manage cache settings and purge |
53
+ | `config` | 10 | Manage CLI configuration and profiles |
54
+ | `custom-hostnames` | 5 | Manage Custom Hostnames (Cloudflare for SaaS) |
55
+ | `email-routing` | 9 | Manage Cloudflare Email Routing rules and addresses |
56
+ | `export` | 2 | Export and backup Cloudflare configuration |
57
+ | `health` | 1 | Health checks |
58
+ | `load-balancers` | 11 | Manage Load Balancers, pools, and monitors |
59
+ | `page-rules` | 5 | Manage Cloudflare Page Rules |
60
+ | `pages` | 13 | Manage Cloudflare Pages projects and deployments |
61
+ | `r2` | 7 | Manage R2 object storage buckets |
62
+ | `records` | 9 | Manage DNS records (CRUD, bulk create, import/export, scan) |
63
+ | `redirects` | 7 | Manage Cloudflare Redirect and Bulk Redirect rules |
64
+ | `selftest` | 1 | Run built-in test suite |
65
+ | `spectrum` | 5 | Manage Spectrum applications |
66
+ | `speed` | 7 | Manage speed optimization settings (minify, polish, mirage) |
67
+ | `ssl` | 7 | Manage SSL/TLS settings and certificates |
68
+ | `status` | 1 | Account status dashboard |
69
+ | `terraform` | 6 | Run Terraform commands for Cloudflare infrastructure |
70
+ | `tunnels` | 8 | Manage Cloudflare Tunnels |
71
+ | `waf` | 12 | Manage WAF and firewall rules |
72
+ | `waiting-rooms` | 5 | Manage Waiting Rooms |
73
+ | `workers` | 17 | Manage Cloudflare Workers, routes, and KV |
74
+ | `zones` | 9 | Manage DNS zones |
75
+
76
+ **Total: ~195 commands across 26 groups.**
77
+
78
+ ## Command Aliases
79
+
80
+ Hidden short aliases are available for common workflows:
81
+
82
+ | Alias | Expands to |
83
+ |-------|-------------------------|
84
+ | `zl` | `zones list` |
85
+ | `zg` | `zones get <zone>` |
86
+ | `rl` | `records list` |
87
+ | `hc` | `health check` |
88
+ | `cs` | `cache status` |
89
+ | `cp` | `cache purge-all` |
90
+ | `ss` | `ssl status` |
91
+ | `wl` | `workers list` |
92
+ | `ea` | `export all` |
93
+ | `tl` | `tunnels list` |
94
+ | `st` | `status overview` |
95
+ | `bk` | `export backup` |
96
+
97
+ Example:
98
+
99
+ ```bash
100
+ kctl-cf zl # same as: kctl-cf zones list
101
+ kctl-cf rl --zone example.com # same as: kctl-cf records list --zone example.com
102
+ kctl-cf cp --zone example.com # same as: kctl-cf cache purge-all --zone example.com --yes
103
+ ```
104
+
105
+ ## Global Options
106
+
107
+ ```
108
+ --json Output as JSON (machine-readable)
109
+ --quiet, -q Suppress informational messages
110
+ --format, -f Output format: pretty/json/csv/yaml (default: pretty)
111
+ --no-header Omit header row in CSV output
112
+ --profile, -p Use a named config profile
113
+ --api-token API token override (skips config file)
114
+ --account-id Account ID override (skips config file)
115
+ --version, -V Show version and exit
116
+ ```
117
+
118
+ Global options are inherited by aliases. For example:
119
+
120
+ ```bash
121
+ kctl-cf --json --profile prod zl # zones list as JSON using 'prod' profile
122
+ ```
123
+
124
+ ## Configuration
125
+
126
+ ### Shared Config File
127
+
128
+ All kctl-* CLIs share a single config file at `~/.config/kodemeio/config.yaml`. kctl-cf uses the `cloudflare` service key for its settings.
129
+
130
+ ### Profiles
131
+
132
+ kctl-cf supports named profiles for managing multiple Cloudflare accounts:
133
+
134
+ ```bash
135
+ # Interactive setup (recommended for first time)
136
+ kctl-cf config init
137
+
138
+ # Add a profile manually
139
+ kctl-cf config add production \
140
+ --api-token $CF_API_TOKEN \
141
+ --account-id $CF_ACCOUNT_ID \
142
+ --default-zone example.com
143
+
144
+ # Add a staging profile
145
+ kctl-cf config add staging \
146
+ --api-token $CF_STAGING_TOKEN \
147
+ --account-id $CF_STAGING_ACCOUNT_ID
148
+
149
+ # Switch default profile
150
+ kctl-cf config use production
151
+
152
+ # Use a profile for a single command
153
+ kctl-cf --profile staging zones list
154
+
155
+ # Show active profile
156
+ kctl-cf config current
157
+
158
+ # List all profiles
159
+ kctl-cf config profiles
160
+
161
+ # Show config (secrets masked)
162
+ kctl-cf config show
163
+
164
+ # Validate config
165
+ kctl-cf config validate
166
+
167
+ # Remove a profile
168
+ kctl-cf config remove staging
169
+ ```
170
+
171
+ ### Environment Variables
172
+
173
+ Config values can be overridden at runtime via CLI flags or environment variables:
174
+
175
+ ```bash
176
+ export CF_API_TOKEN=your-token
177
+ export CF_ACCOUNT_ID=your-account-id
178
+ kctl-cf zones list
179
+ ```
180
+
181
+ ### Default Zone
182
+
183
+ Set a default zone in your profile to avoid passing `--zone` on every command:
184
+
185
+ ```bash
186
+ kctl-cf config set default_zone example.com
187
+ ```
188
+
189
+ ## Common Workflows
190
+
191
+ ### DNS Management
192
+
193
+ ```bash
194
+ # List all A records for a zone
195
+ kctl-cf records list --zone example.com --type A
196
+
197
+ # Create a new DNS record
198
+ kctl-cf records create \
199
+ --zone example.com \
200
+ --type A \
201
+ --name api.example.com \
202
+ --content 1.2.3.4 \
203
+ --proxied
204
+
205
+ # Update an existing record
206
+ kctl-cf records update <record-id> --content 5.6.7.8 --zone example.com
207
+
208
+ # Delete a record (requires --force)
209
+ kctl-cf records delete <record-id> --force --zone example.com
210
+
211
+ # Bulk create from JSON file
212
+ kctl-cf records bulk-create --file records.json --zone example.com
213
+
214
+ # Import BIND zone file
215
+ kctl-cf records import --file zone.txt --zone example.com
216
+
217
+ # Export records as BIND format
218
+ kctl-cf records export --zone example.com --file backup.txt
219
+ ```
220
+
221
+ ### Cache
222
+
223
+ ```bash
224
+ # Purge all cache
225
+ kctl-cf cache purge-all --zone example.com
226
+
227
+ # Check cache status
228
+ kctl-cf cache status --zone example.com
229
+ ```
230
+
231
+ ### WAF & Security
232
+
233
+ ```bash
234
+ # List WAF rules
235
+ kctl-cf waf list --zone example.com
236
+
237
+ # List firewall rules
238
+ kctl-cf waf firewall-list --zone example.com
239
+ ```
240
+
241
+ ### Tunnels
242
+
243
+ ```bash
244
+ # List tunnels
245
+ kctl-cf tunnels list
246
+
247
+ # Get tunnel details
248
+ kctl-cf tunnels get <tunnel-id>
249
+
250
+ # List tunnel connectors
251
+ kctl-cf tunnels connectors <tunnel-id>
252
+ ```
253
+
254
+ ### Workers
255
+
256
+ ```bash
257
+ # List all workers
258
+ kctl-cf workers list
259
+
260
+ # Deploy a worker script
261
+ kctl-cf workers deploy --name my-worker --file worker.js
262
+
263
+ # List KV namespaces
264
+ kctl-cf workers kv-list
265
+ ```
266
+
267
+ ### Export & Backup
268
+
269
+ ```bash
270
+ # Export all zone config
271
+ kctl-cf export all --zone example.com
272
+
273
+ # Full account backup
274
+ kctl-cf export backup
275
+ ```
276
+
277
+ ## Shell Completions
278
+
279
+ ```bash
280
+ # Install for your shell
281
+ kctl-cf --install-completion bash
282
+ kctl-cf --install-completion zsh
283
+ kctl-cf --install-completion fish
284
+ ```
285
+
286
+ ## Plugin Development
287
+
288
+ kctl-cf supports extending the CLI via Python entry points. Create a package that registers a Typer app under the `kctl_cf.plugins` entry point group:
289
+
290
+ ```toml
291
+ # In your plugin's pyproject.toml
292
+ [project.entry-points."kctl_cf.plugins"]
293
+ my_plugin = "my_plugin.cli:app"
294
+ ```
295
+
296
+ The plugin's `app` (a `typer.Typer` instance) will be registered as a command group automatically on startup.
297
+
298
+ ## Development
299
+
300
+ ### Running Tests
301
+
302
+ ```bash
303
+ cd packages/kctl-cf
304
+ uv run pytest tests/ -v
305
+ ```
306
+
307
+ ### Linting and Formatting
308
+
309
+ ```bash
310
+ cd packages/kctl-cf
311
+ uv run ruff check src/
312
+ uv run ruff format src/
313
+ ```
314
+
315
+ ### Type Checking
316
+
317
+ ```bash
318
+ cd packages/kctl-cf
319
+ uv run mypy src/kctl_cf/
320
+ ```
321
+
322
+ ### Project Structure
323
+
324
+ ```
325
+ packages/kctl-cf/
326
+ src/kctl_cf/
327
+ cli.py Main app + command registration
328
+ __init__.py Version
329
+ core/
330
+ callbacks.py Global option handling (AppContext)
331
+ api_client.py Cloudflare API client (wraps kctl-lib APIClient)
332
+ config.py Profile/config management
333
+ exceptions.py Custom exception hierarchy
334
+ output.py Output formatting (table, JSON, plain)
335
+ utils.py Zone resolution and shared helpers
336
+ commands/
337
+ aliases.py Short command aliases
338
+ access.py Zero Trust Access
339
+ analytics.py Zone analytics
340
+ argo.py Argo Smart Routing
341
+ cache.py Cache management
342
+ config_cmd.py Config subcommands
343
+ custom_hostnames.py Cloudflare for SaaS
344
+ email_routing.py Email Routing
345
+ export.py Export/backup
346
+ health.py Health checks
347
+ load_balancers.py Load Balancers
348
+ page_rules.py Page Rules
349
+ pages.py Cloudflare Pages
350
+ r2.py R2 object storage
351
+ records.py DNS records
352
+ redirects.py Redirect rules
353
+ selftest.py Built-in test suite
354
+ spectrum.py Spectrum apps
355
+ speed.py Speed optimization
356
+ ssl.py SSL/TLS settings
357
+ status.py Account status
358
+ terraform.py Terraform integration
359
+ tunnels.py Cloudflare Tunnels
360
+ waf.py WAF and firewall rules
361
+ waiting_rooms.py Waiting Rooms
362
+ workers.py Workers, routes, KV
363
+ zones.py DNS zones
364
+ tests/ pytest test suite
365
+ pyproject.toml Package metadata and tool config
366
+ README.md This file
367
+ ```
@@ -0,0 +1,6 @@
1
+ FROM cloudflare/cloudflared:latest
2
+
3
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
4
+ CMD cloudflared tunnel info || exit 1
5
+
6
+ ENTRYPOINT ["cloudflared", "tunnel", "--no-autoupdate", "run"]
@@ -0,0 +1,38 @@
1
+ services:
2
+ cloudflared:
3
+ image: cloudflare/cloudflared:latest
4
+ container_name: kodemeio-cloudflared
5
+ restart: unless-stopped
6
+ command: tunnel --no-autoupdate run
7
+ environment:
8
+ - TUNNEL_TOKEN=${TUNNEL_TOKEN}
9
+ networks:
10
+ - dokploy-network
11
+ deploy:
12
+ resources:
13
+ limits:
14
+ cpus: "0.50"
15
+ memory: 256M
16
+ reservations:
17
+ cpus: "0.10"
18
+ memory: 64M
19
+ healthcheck:
20
+ test: ["CMD", "cloudflared", "tunnel", "info"]
21
+ interval: 30s
22
+ timeout: 10s
23
+ start_period: 10s
24
+ retries: 3
25
+ logging:
26
+ driver: json-file
27
+ options:
28
+ max-size: "10m"
29
+ max-file: "3"
30
+ tag: "kodemeio-cloudflared"
31
+ labels:
32
+ - "promtail.enabled=true"
33
+ - "promtail.job=cloudflared"
34
+ - "com.centurylinklabs.watchtower.enable=true"
35
+
36
+ networks:
37
+ dokploy-network:
38
+ external: true
@@ -0,0 +1,46 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "kctl-cf"
7
+ version = "0.3.0"
8
+ description = "Kodemeio Cloudflare CLI — manage Cloudflare infrastructure"
9
+ requires-python = ">=3.12"
10
+ dependencies = [
11
+ "kctl-lib>=0.4.0",
12
+ "typer>=0.15.0",
13
+ "rich>=13.9.0",
14
+ "pydantic>=2.10.0",
15
+ "pyyaml>=6.0.2",
16
+ "httpx>=0.28.0",
17
+ ]
18
+
19
+ [project.optional-dependencies]
20
+ dev = [
21
+ "pytest>=8.3.0",
22
+ "pytest-httpx>=0.35.0",
23
+ "pytest-cov>=6.0.0",
24
+ "ruff>=0.9.0",
25
+ "mypy>=1.14.0",
26
+ "types-PyYAML>=6.0.0",
27
+ ]
28
+
29
+ [project.scripts]
30
+ kctl-cf = "kctl_cf.cli:_run"
31
+
32
+ [tool.uv.sources]
33
+ kctl-lib = { workspace = true }
34
+
35
+ [project.entry-points."kctl_cf.plugins"]
36
+
37
+ [tool.hatch.build.targets.wheel]
38
+ packages = ["src/kctl_cf"]
39
+
40
+ [tool.ruff]
41
+ target-version = "py312"
42
+ line-length = 120
43
+
44
+ [tool.mypy]
45
+ python_version = "3.12"
46
+ strict = true