costguard-cli 1.0.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,6 @@
1
+ Copyright (c) 2025-2026 SKYXOPS. All rights reserved.
2
+
3
+ This software is proprietary and confidential. Unauthorized copying, distribution,
4
+ modification, or use of this software, via any medium, is strictly prohibited.
5
+
6
+ For licensing inquiries, contact: engineering@skyxops.com
@@ -0,0 +1,133 @@
1
+ Metadata-Version: 2.4
2
+ Name: costguard-cli
3
+ Version: 1.0.0
4
+ Summary: CostGuard CI/CD validation CLI — shift-left cost governance for cloud infrastructure
5
+ Author-email: SKYXOPS <engineering@skyxops.com>
6
+ License-Expression: LicenseRef-Proprietary
7
+ Project-URL: Homepage, https://skyxops.com/costguard
8
+ Project-URL: Documentation, https://docs.skyxops.com/costguard-cli
9
+ Project-URL: Repository, https://dev.azure.com/skyxops/basecamp/_git/costguard-cli
10
+ Project-URL: Changelog, https://dev.azure.com/skyxops/basecamp/_git/costguard-cli?path=/CHANGELOG.md
11
+ Keywords: costguard,cost,governance,finops,cloud,terraform,cloudformation,iac,ci-cd,budget,guardrails,skyxops
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: System Administrators
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Topic :: Software Development :: Build Tools
24
+ Classifier: Topic :: System :: Systems Administration
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.9
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Provides-Extra: dev
30
+ Requires-Dist: pytest>=7.0; extra == "dev"
31
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
32
+ Requires-Dist: build>=1.0.0; extra == "dev"
33
+ Requires-Dist: twine>=5.0.0; extra == "dev"
34
+ Dynamic: license-file
35
+
36
+ # CostGuard CLI
37
+
38
+ Shift-left cost governance for CI/CD pipelines. One command validates your Terraform plan against cost policies, budget limits, and guardrails — before infrastructure is deployed.
39
+
40
+ ## Install
41
+
42
+ ```bash
43
+ pip install costguard-cli
44
+ ```
45
+
46
+ ## Usage
47
+
48
+ ```bash
49
+ # Validate a Terraform plan
50
+ costguard-validate --plan plan.json --format terminal
51
+
52
+ # Post results as PR/MR comment (auto-detects GitLab/GitHub/Azure DevOps)
53
+ costguard-validate --plan plan.json --format markdown --post-comment
54
+
55
+ # Use cached result across pipeline stages
56
+ costguard-validate --cached costguard-result.json --format html --output-file report.html
57
+ ```
58
+
59
+ ## Configuration
60
+
61
+ | Option | Env Variable | Description |
62
+ |--------|-------------|-------------|
63
+ | `--api-url` | `COSTGUARD_API_URL` | CostGuard API endpoint |
64
+ | `--api-key` | `COSTGUARD_API_KEY` | API authentication key |
65
+ | `--budget-id` | `COSTGUARD_BUDGET_ID` | Budget UUID to validate against |
66
+
67
+ ## Output Formats
68
+
69
+ | Format | Use Case |
70
+ |--------|----------|
71
+ | `terminal` | Local development, CI logs |
72
+ | `markdown` | PR/MR comments |
73
+ | `html` | Executive reports, artifacts |
74
+ | `json` | Machine-readable, integrations |
75
+
76
+ ## Exit Codes
77
+
78
+ | Code | Decision | Meaning |
79
+ |------|----------|---------|
80
+ | 0 | ALLOW | Deployment permitted |
81
+ | 1 | BLOCK | Deployment blocked by guardrails |
82
+ | 2 | WARN | Deployment allowed with warnings |
83
+ | 3 | ERROR | Validation could not complete |
84
+
85
+ ## CI/CD Integration
86
+
87
+ ### GitLab CI
88
+
89
+ ```yaml
90
+ costguard:
91
+ script:
92
+ - pip install costguard-cli
93
+ - terraform show -json plan.tfplan > plan.json
94
+ - costguard-validate --plan plan.json --format terminal --post-comment
95
+ variables:
96
+ COSTGUARD_API_URL: $COSTGUARD_API_URL
97
+ COSTGUARD_API_KEY: $COSTGUARD_API_KEY
98
+ ```
99
+
100
+ ### GitHub Actions
101
+
102
+ ```yaml
103
+ - name: CostGuard Validation
104
+ env:
105
+ COSTGUARD_API_URL: ${{ secrets.COSTGUARD_API_URL }}
106
+ COSTGUARD_API_KEY: ${{ secrets.COSTGUARD_API_KEY }}
107
+ run: |
108
+ pip install costguard-cli
109
+ terraform show -json plan.tfplan > plan.json
110
+ costguard-validate --plan plan.json --format terminal --post-comment
111
+ ```
112
+
113
+ ### Azure DevOps
114
+
115
+ ```yaml
116
+ - script: |
117
+ pip install costguard-cli
118
+ terraform show -json plan.tfplan > plan.json
119
+ costguard-validate --plan plan.json --format terminal --post-comment
120
+ env:
121
+ COSTGUARD_API_URL: $(COSTGUARD_API_URL)
122
+ COSTGUARD_API_KEY: $(COSTGUARD_API_KEY)
123
+ ```
124
+
125
+ ## How It Works
126
+
127
+ 1. Reads `plan.json` (output of `terraform show -json`)
128
+ 2. Sends it to the CostGuard API
129
+ 3. Receives cost breakdown, policy violations, budget status, and AI recommendations
130
+ 4. Formats and displays results
131
+ 5. Exits with appropriate code so the pipeline can ALLOW, WARN, or BLOCK
132
+
133
+ No cloud credentials required — the CLI only reads the plan file. All resource details are already in the Terraform plan output.
@@ -0,0 +1,98 @@
1
+ # CostGuard CLI
2
+
3
+ Shift-left cost governance for CI/CD pipelines. One command validates your Terraform plan against cost policies, budget limits, and guardrails — before infrastructure is deployed.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install costguard-cli
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```bash
14
+ # Validate a Terraform plan
15
+ costguard-validate --plan plan.json --format terminal
16
+
17
+ # Post results as PR/MR comment (auto-detects GitLab/GitHub/Azure DevOps)
18
+ costguard-validate --plan plan.json --format markdown --post-comment
19
+
20
+ # Use cached result across pipeline stages
21
+ costguard-validate --cached costguard-result.json --format html --output-file report.html
22
+ ```
23
+
24
+ ## Configuration
25
+
26
+ | Option | Env Variable | Description |
27
+ |--------|-------------|-------------|
28
+ | `--api-url` | `COSTGUARD_API_URL` | CostGuard API endpoint |
29
+ | `--api-key` | `COSTGUARD_API_KEY` | API authentication key |
30
+ | `--budget-id` | `COSTGUARD_BUDGET_ID` | Budget UUID to validate against |
31
+
32
+ ## Output Formats
33
+
34
+ | Format | Use Case |
35
+ |--------|----------|
36
+ | `terminal` | Local development, CI logs |
37
+ | `markdown` | PR/MR comments |
38
+ | `html` | Executive reports, artifacts |
39
+ | `json` | Machine-readable, integrations |
40
+
41
+ ## Exit Codes
42
+
43
+ | Code | Decision | Meaning |
44
+ |------|----------|---------|
45
+ | 0 | ALLOW | Deployment permitted |
46
+ | 1 | BLOCK | Deployment blocked by guardrails |
47
+ | 2 | WARN | Deployment allowed with warnings |
48
+ | 3 | ERROR | Validation could not complete |
49
+
50
+ ## CI/CD Integration
51
+
52
+ ### GitLab CI
53
+
54
+ ```yaml
55
+ costguard:
56
+ script:
57
+ - pip install costguard-cli
58
+ - terraform show -json plan.tfplan > plan.json
59
+ - costguard-validate --plan plan.json --format terminal --post-comment
60
+ variables:
61
+ COSTGUARD_API_URL: $COSTGUARD_API_URL
62
+ COSTGUARD_API_KEY: $COSTGUARD_API_KEY
63
+ ```
64
+
65
+ ### GitHub Actions
66
+
67
+ ```yaml
68
+ - name: CostGuard Validation
69
+ env:
70
+ COSTGUARD_API_URL: ${{ secrets.COSTGUARD_API_URL }}
71
+ COSTGUARD_API_KEY: ${{ secrets.COSTGUARD_API_KEY }}
72
+ run: |
73
+ pip install costguard-cli
74
+ terraform show -json plan.tfplan > plan.json
75
+ costguard-validate --plan plan.json --format terminal --post-comment
76
+ ```
77
+
78
+ ### Azure DevOps
79
+
80
+ ```yaml
81
+ - script: |
82
+ pip install costguard-cli
83
+ terraform show -json plan.tfplan > plan.json
84
+ costguard-validate --plan plan.json --format terminal --post-comment
85
+ env:
86
+ COSTGUARD_API_URL: $(COSTGUARD_API_URL)
87
+ COSTGUARD_API_KEY: $(COSTGUARD_API_KEY)
88
+ ```
89
+
90
+ ## How It Works
91
+
92
+ 1. Reads `plan.json` (output of `terraform show -json`)
93
+ 2. Sends it to the CostGuard API
94
+ 3. Receives cost breakdown, policy violations, budget status, and AI recommendations
95
+ 4. Formats and displays results
96
+ 5. Exits with appropriate code so the pipeline can ALLOW, WARN, or BLOCK
97
+
98
+ No cloud credentials required — the CLI only reads the plan file. All resource details are already in the Terraform plan output.
@@ -0,0 +1,3 @@
1
+ """CostGuard CLI — shift-left cost governance for CI/CD pipelines."""
2
+
3
+ __version__ = "1.0.0"
@@ -0,0 +1,5 @@
1
+ """Allow running CostGuard CLI via `python -m costguard_cli`."""
2
+
3
+ from costguard_cli.validate import main
4
+
5
+ main()
@@ -0,0 +1,15 @@
1
+ """CostGuard output formatters."""
2
+
3
+ from costguard_cli.formatters.terminal import TerminalFormatter
4
+ from costguard_cli.formatters.markdown import MarkdownFormatter
5
+ from costguard_cli.formatters.json_report import JsonFormatter
6
+ from costguard_cli.formatters.html_report import HtmlFormatter
7
+
8
+ FORMATTERS = {
9
+ "terminal": TerminalFormatter,
10
+ "markdown": MarkdownFormatter,
11
+ "json": JsonFormatter,
12
+ "html": HtmlFormatter,
13
+ }
14
+
15
+ __all__ = ["FORMATTERS", "TerminalFormatter", "MarkdownFormatter", "JsonFormatter", "HtmlFormatter"]