Skip to content

Commit

Permalink
enhance: update feedback link to go to the Infracost Cloud endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
aliscott committed Jul 8, 2022
1 parent 5a58d88 commit 4daea90
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 28 deletions.
7 changes: 4 additions & 3 deletions cmd/infracost/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ func buildCommentBody(cmd *cobra.Command, ctx *config.RunContext, paths []string
}

opts := output.Options{
NoColor: ctx.Config.NoColor,
ShowSkipped: true,
PolicyChecks: policyChecks,
DashboardEndpoint: ctx.Config.DashboardEndpoint,
NoColor: ctx.Config.NoColor,
ShowSkipped: true,
PolicyChecks: policyChecks,
}

b, err := output.ToMarkdown(combined, opts, mdOpts)
Expand Down
7 changes: 4 additions & 3 deletions cmd/infracost/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ func runCompare(cmd *cobra.Command, ctx *config.RunContext, current output.Root)

format, _ := cmd.Flags().GetString("format")
b, err := output.FormatOutput(strings.ToLower(format), combined, output.Options{
ShowSkipped: ctx.Config.ShowSkipped,
NoColor: ctx.Config.NoColor,
Fields: ctx.Config.Fields,
DashboardEndpoint: ctx.Config.DashboardEndpoint,
ShowSkipped: ctx.Config.ShowSkipped,
NoColor: ctx.Config.NoColor,
Fields: ctx.Config.Fields,
})
if err != nil {
return err
Expand Down
5 changes: 3 additions & 2 deletions cmd/infracost/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ func outputCmd(ctx *config.RunContext) *cobra.Command {
}

opts := output.Options{
NoColor: ctx.Config.NoColor,
Fields: fields,
DashboardEndpoint: ctx.Config.DashboardEndpoint,
NoColor: ctx.Config.NoColor,
Fields: fields,
}
opts.ShowSkipped, _ = cmd.Flags().GetBool("show-skipped")

Expand Down
7 changes: 4 additions & 3 deletions cmd/infracost/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,10 @@ func runMain(cmd *cobra.Command, runCtx *config.RunContext) error {
}

b, err := output.FormatOutput(format, r, output.Options{
ShowSkipped: runCtx.Config.ShowSkipped,
NoColor: runCtx.Config.NoColor,
Fields: runCtx.Config.Fields,
DashboardEndpoint: runCtx.Config.DashboardEndpoint,
ShowSkipped: runCtx.Config.ShowSkipped,
NoColor: runCtx.Config.NoColor,
Fields: runCtx.Config.Fields,
})
if err != nil {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Key: ~ changed, + added, - removed
This comment will be updated when the cost estimate changes.

<sub>
Is this comment useful? <a href="https://www.infracost.io/feedback/submit/?value=yes" rel="noopener noreferrer" target="_blank">Yes</a>, <a href="https://www.infracost.io/feedback/submit/?value=no" rel="noopener noreferrer" target="_blank">No</a>, <a href="https://www.infracost.io/feedback/submit/?value=other" rel="noopener noreferrer" target="_blank">Other</a>
Is this comment useful? <a href="https://dashboard.infracost.io/feedback/redirect?runId=&value=yes" rel="noopener noreferrer" target="_blank">Yes</a>, <a href="https://dashboard.infracost.io/feedback/redirect?runId=&value=no" rel="noopener noreferrer" target="_blank">No</a>, <a href="https://dashboard.infracost.io/feedback/redirect?runId=&value=other" rel="noopener noreferrer" target="_blank">Other</a>
</sub>

Comment not posted to Azure Repos (--dry-run was specified)
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ Key: ~ changed, + added, - removed
∙ 2 x aws_iam_role
∙ 2 x aws_iam_role_policy_attachment
```

Is this comment useful? [Yes](https://www.infracost.io/feedback/submit/?value=yes), [No](https://www.infracost.io/feedback/submit/?value=no), [Other](https://www.infracost.io/feedback/submit/?value=other)
Is this comment useful? [Yes](https://dashboard.infracost.io/feedback/redirect?runId=&value=yes), [No](https://dashboard.infracost.io/feedback/redirect?runId=&value=no), [Other](https://dashboard.infracost.io/feedback/redirect?runId=&value=other)

Comment not posted to Bitbucket (--dry-run was specified)
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ Key: ~ changed, + added, - removed
```

This comment will be updated when the cost estimate changes.

Is this comment useful? [Yes](https://www.infracost.io/feedback/submit/?value=yes), [No](https://www.infracost.io/feedback/submit/?value=no), [Other](https://www.infracost.io/feedback/submit/?value=other)
Is this comment useful? [Yes](https://dashboard.infracost.io/feedback/redirect?runId=&value=yes), [No](https://dashboard.infracost.io/feedback/redirect?runId=&value=no), [Other](https://dashboard.infracost.io/feedback/redirect?runId=&value=other)

Comment not posted to Bitbucket (--dry-run was specified)
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Key: ~ changed, + added, - removed
</details>

<sub>
Is this comment useful? <a href="https://www.infracost.io/feedback/submit/?value=yes" rel="noopener noreferrer" target="_blank">Yes</a>, <a href="https://www.infracost.io/feedback/submit/?value=no" rel="noopener noreferrer" target="_blank">No</a>, <a href="https://www.infracost.io/feedback/submit/?value=other" rel="noopener noreferrer" target="_blank">Other</a>
Is this comment useful? <a href="https://dashboard.infracost.io/feedback/redirect?runId=&value=yes" rel="noopener noreferrer" target="_blank">Yes</a>, <a href="https://dashboard.infracost.io/feedback/redirect?runId=&value=no" rel="noopener noreferrer" target="_blank">No</a>, <a href="https://dashboard.infracost.io/feedback/redirect?runId=&value=other" rel="noopener noreferrer" target="_blank">Other</a>
</sub>

Comment not posted to GitHub (--dry-run was specified)
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Key: ~ changed, + added, - removed
This comment will be updated when the cost estimate changes.

<sub>
Is this comment useful? <a href="https://www.infracost.io/feedback/submit/?value=yes" rel="noopener noreferrer" target="_blank">Yes</a>, <a href="https://www.infracost.io/feedback/submit/?value=no" rel="noopener noreferrer" target="_blank">No</a>, <a href="https://www.infracost.io/feedback/submit/?value=other" rel="noopener noreferrer" target="_blank">Other</a>
Is this comment useful? <a href="https://dashboard.infracost.io/feedback/redirect?runId=&value=yes" rel="noopener noreferrer" target="_blank">Yes</a>, <a href="https://dashboard.infracost.io/feedback/redirect?runId=&value=no" rel="noopener noreferrer" target="_blank">No</a>, <a href="https://dashboard.infracost.io/feedback/redirect?runId=&value=other" rel="noopener noreferrer" target="_blank">Other</a>
</sub>

Comment not posted to GitHub (--dry-run was specified)
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Key: ~ changed, + added, - removed
</details>

<sub>
Is this comment useful? <a href="https://www.infracost.io/feedback/submit/?value=yes" rel="noopener noreferrer" target="_blank">Yes</a>, <a href="https://www.infracost.io/feedback/submit/?value=no" rel="noopener noreferrer" target="_blank">No</a>, <a href="https://www.infracost.io/feedback/submit/?value=other" rel="noopener noreferrer" target="_blank">Other</a>
Is this comment useful? <a href="https://dashboard.infracost.io/feedback/redirect?runId=&value=yes" rel="noopener noreferrer" target="_blank">Yes</a>, <a href="https://dashboard.infracost.io/feedback/redirect?runId=&value=no" rel="noopener noreferrer" target="_blank">No</a>, <a href="https://dashboard.infracost.io/feedback/redirect?runId=&value=other" rel="noopener noreferrer" target="_blank">Other</a>
</sub>

Comment not posted to GitLab (--dry-run was specified)
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Key: ~ changed, + added, - removed
This comment will be updated when the cost estimate changes.

<sub>
Is this comment useful? <a href="https://www.infracost.io/feedback/submit/?value=yes" rel="noopener noreferrer" target="_blank">Yes</a>, <a href="https://www.infracost.io/feedback/submit/?value=no" rel="noopener noreferrer" target="_blank">No</a>, <a href="https://www.infracost.io/feedback/submit/?value=other" rel="noopener noreferrer" target="_blank">Other</a>
Is this comment useful? <a href="https://dashboard.infracost.io/feedback/redirect?runId=&value=yes" rel="noopener noreferrer" target="_blank">Yes</a>, <a href="https://dashboard.infracost.io/feedback/redirect?runId=&value=no" rel="noopener noreferrer" target="_blank">No</a>, <a href="https://dashboard.infracost.io/feedback/redirect?runId=&value=other" rel="noopener noreferrer" target="_blank">Other</a>
</sub>

Comment not posted to GitLab (--dry-run was specified)
11 changes: 6 additions & 5 deletions internal/output/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,12 @@ type SummaryOptions struct {
}

type Options struct {
NoColor bool
ShowSkipped bool
Fields []string
IncludeHTML bool
PolicyChecks PolicyCheck
DashboardEndpoint string
NoColor bool
ShowSkipped bool
Fields []string
IncludeHTML bool
PolicyChecks PolicyCheck
}

// PolicyCheck holds information if a given run has any policy checks enabled.
Expand Down
6 changes: 4 additions & 2 deletions internal/output/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,8 @@ This comment will be replaced when the cost estimate changes
{{- if .MarkdownOptions.IncludeFeedbackLink }}
<sub>
Is this comment useful? <a href="https://www.infracost.io/feedback/submit/?value=yes" rel="noopener noreferrer" target="_blank">Yes</a>, <a href="https://www.infracost.io/feedback/submit/?value=no" rel="noopener noreferrer" target="_blank">No</a>, <a href="https://www.infracost.io/feedback/submit/?value=other" rel="noopener noreferrer" target="_blank">Other</a>
{{- $feedbackURL := (print .Options.DashboardEndpoint "/feedback/redirect?runId=" .Root.RunID) }}
Is this comment useful? <a href="{{ $feedbackURL }}&value=yes" rel="noopener noreferrer" target="_blank">Yes</a>, <a href="{{ $feedbackURL }}&value=no" rel="noopener noreferrer" target="_blank">No</a>, <a href="{{ $feedbackURL }}&value=other" rel="noopener noreferrer" target="_blank">Other</a>
</sub>
{{- end}}
`
Expand Down Expand Up @@ -450,6 +451,7 @@ This comment will be replaced when the cost estimate changes
{{- end }}
{{- if .MarkdownOptions.IncludeFeedbackLink }}
Is this comment useful? [Yes](https://www.infracost.io/feedback/submit/?value=yes), [No](https://www.infracost.io/feedback/submit/?value=no), [Other](https://www.infracost.io/feedback/submit/?value=other)
{{- $feedbackURL := (print .Options.DashboardEndpoint "/feedback/redirect?runId=" .Root.RunID) }}
Is this comment useful? [Yes]({{ $feedbackURL }}&value=yes), [No]({{ $feedbackURL }}&value=no), [Other]({{ $feedbackURL }}&value=other)
{{- end }}
`
2 changes: 1 addition & 1 deletion scripts/ci/diff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ build_msg () {
msg+="\n$update_msg\n\n"
fi
msg+="<sub>\n"
msg+=" Is this comment useful? <a href=\"https://www.infracost.io/feedback/submit/?value=yes\" rel=\"noopener noreferrer\" target=\"_blank\">Yes</a>, <a href=\"https://www.infracost.io/feedback/submit/?value=no\" rel=\"noopener noreferrer\" target=\"_blank\">No</a>, <a href=\"https://www.infracost.io/feedback/submit/?value=other\" rel=\"noopener noreferrer\" target=\"_blank\">Other</a>\n"
msg+=" Is this comment useful? <a href=\"https://dashboard.infracost.io/feedback/redirect?value=yes\" rel=\"noopener noreferrer\" target=\"_blank\">Yes</a>, <a href=\"https://dashboard.infracost.io/feedback/redirect?value=no\" rel=\"noopener noreferrer\" target=\"_blank\">No</a>, <a href=\"https://dashboard.infracost.io/feedback/redirect?value=other\" rel=\"noopener noreferrer\" target=\"_blank\">Other</a>\n"
msg+="</sub>\n"
fi

Expand Down

0 comments on commit 4daea90

Please sign in to comment.