You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For GitHub Enterprise, set `Options.APIURL` to your instance URL.
13
+
For GitHub Enterprise, set `Options.APIURL` to your instance URL. You can also provide a custom `Options.TLSConfig` for Enterprise TLS requirements.
14
14
15
15
### 2. Build the comment data
16
16
17
-
Populate a `vcs.CommentData` struct with cost and policy data from your run. All fields use shared prototypes from `github.com/infracost/proto`.
17
+
Populate a `comment.Data` struct with cost and policy data from your run. Cost fields use `*rat.Rat` from `github.com/infracost/go-proto/pkg/rat`, and policy fields use proto types from `github.com/infracost/proto` and `github.com/infracost/go-proto`.
18
18
19
19
```go
20
-
data:=vcs.CommentData{
20
+
data:=comment.Data{
21
21
Currency: "USD",
22
22
TotalMonthlyCost: totalCost,
23
23
PastTotalMonthlyCost: pastCost,
24
-
Projects: []vcs.ProjectResult{
24
+
Projects: []comment.ProjectResult{
25
25
{
26
26
Name: "my-project",
27
27
TotalMonthlyCost: projectCost,
28
-
Resources: output.GetResources(),
29
-
DiffResources: diffResources,
28
+
Breakdown: breakdown,
29
+
Resources: resources,
30
30
},
31
31
},
32
32
}
33
33
```
34
34
35
+
#### `comment.Data` fields
36
+
37
+
| Field | Type | Description |
38
+
|---|---|---|
39
+
|`EnableEnvironmentalMetrics`|`bool`| Show carbon emissions in the comment. |
40
+
|`NeverShowCostEstimate`|`bool`| Suppress the cost details section entirely. |
41
+
|`UsedUsageFile`|`bool`| Whether an `infracost-usage.yml` was used. |
42
+
|`UsageAPIEnabled`|`bool`| Whether Infracost Cloud usage API estimates are enabled. |
43
+
|`OrgSlug`|`string`| Organization slug for Infracost Cloud links. |
44
+
|`RepoID`|`string`| Repository ID for Infracost Cloud links. |
45
+
|`BaseBranchName`|`string`| Default/base branch name (e.g. `"main"`). |
46
+
|`Currency`|`string`| ISO 4217 currency code (e.g. `"USD"`). |
47
+
|`TotalMonthlyCost`|`*rat.Rat`| Current total monthly cost across all projects. |
48
+
|`PastTotalMonthlyCost`|`*rat.Rat`| Previous total monthly cost (from base branch). Nil if no previous run. |
49
+
|`DiffTotalMonthlyCarbonGramsCo2e`|`*rat.Rat`| Change in monthly carbon emissions (grams CO2e). |
50
+
|`CloudURL`|`string`| Link to the Infracost Cloud dashboard for this run. |
51
+
|`RepoURL`|`string`| VCS repository URL, used for source links in governance tables. |
52
+
|`CommitSHA`|`string`| Head commit SHA, used with `RepoURL` for source links. |
53
+
|`Summary`|`ResourceSummary`| Aggregated resource counts across all projects. |
54
+
|`Projects`|`[]ProjectResult`| Per-project cost and resource data. |
55
+
|`FinOpsPolicyResults`|`[]*provider.FinopsPolicyResult`| FinOps policy results for the current run. |
56
+
|`PreviousFinOpsPolicyResults`|`[]*provider.FinopsPolicyResult`| FinOps policy results from the previous run. |
57
+
|`SecurityPolicyResults`|`[]*provider.FinopsPolicyResult`| Security policy results for the current run. |
58
+
|`PreviousSecurityPolicyResults`|`[]*provider.FinopsPolicyResult`| Security policy results from the previous run. |
59
+
|`TaggingPolicyResults`|`[]*event.TaggingPolicyResult`| Tagging policy results for the current run. |
60
+
|`PreviousTaggingPolicyResults`|`[]*event.TaggingPolicyResult`| Tagging policy results from the previous run. |
61
+
|`GuardrailResults`|`[]*event.GuardrailResult`| Guardrail results for the current run. |
62
+
|`PreviousGuardrailResults`|`[]*event.GuardrailResult`| Guardrail results from the previous run. |
63
+
64
+
#### `comment.ProjectResult` fields
65
+
66
+
| Field | Type | Description |
67
+
|---|---|---|
68
+
|`Name`|`string`| Project name from configuration. |
69
+
|`ModulePath`|`string`| Terraform module path, if applicable. |
70
+
|`Workspace`|`string`| Terraform workspace name, if applicable. |
71
+
|`TotalMonthlyCost`|`*rat.Rat`| Current total monthly cost for this project. |
72
+
|`PastTotalMonthlyCost`|`*rat.Rat`| Previous total monthly cost for this project. |
73
+
|`TotalMonthlyUsageCost`|`*rat.Rat`| Current usage-based monthly cost. |
`PostResult.Posted` indicates whether a comment was created or updated. If it was skipped (e.g. duplicate or stale), `PostResult.SkipReason` explains why.
90
+
42
91
## Comment behaviors
43
92
44
93
`PostComment` accepts a `vcs.Behavior` that controls how comments are managed:
0 commit comments