mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-08-09 12:48:31 +00:00
Merge pull request #960 from runatlantis/long-folding
Add flag for disabling markdown formatting
This commit is contained in:
@@ -53,6 +53,7 @@ const (
|
||||
DataDirFlag = "data-dir"
|
||||
DefaultTFVersionFlag = "default-tf-version"
|
||||
DisableApplyAllFlag = "disable-apply-all"
|
||||
DisableMarkdownFoldingFlag = "disable-markdown-folding"
|
||||
GHHostnameFlag = "gh-hostname"
|
||||
GHTokenFlag = "gh-token"
|
||||
GHUserFlag = "gh-user"
|
||||
@@ -273,6 +274,10 @@ var boolFlags = map[string]boolFlag{
|
||||
description: "Silences the posting of whitelist error comments.",
|
||||
defaultValue: false,
|
||||
},
|
||||
DisableMarkdownFoldingFlag: {
|
||||
description: "Toggle off folding in markdown output.",
|
||||
defaultValue: false,
|
||||
},
|
||||
WriteGitCredsFlag: {
|
||||
description: "Write out a .git-credentials file with the provider user and token to allow cloning private modules over HTTPS or SSH." +
|
||||
" This writes secrets to disk and should only be enabled in a secure environment.",
|
||||
|
||||
@@ -65,6 +65,7 @@ var testFlags = map[string]interface{}{
|
||||
DataDirFlag: "/path",
|
||||
DefaultTFVersionFlag: "v0.11.0",
|
||||
DisableApplyAllFlag: true,
|
||||
DisableMarkdownFoldingFlag: true,
|
||||
GHHostnameFlag: "ghhostname",
|
||||
GHTokenFlag: "token",
|
||||
GHUserFlag: "user",
|
||||
|
||||
@@ -38,6 +38,7 @@ type MarkdownRenderer struct {
|
||||
// If we're not configured with a GitLab client, this will be false.
|
||||
GitlabSupportsCommonMark bool
|
||||
DisableApplyAll bool
|
||||
DisableMarkdownFolding bool
|
||||
}
|
||||
|
||||
// commonData is data that all responses have.
|
||||
@@ -172,6 +173,10 @@ func (m *MarkdownRenderer) renderProjectResults(results []models.ProjectResult,
|
||||
// load. Some VCS providers or versions of VCS providers don't support this
|
||||
// syntax.
|
||||
func (m *MarkdownRenderer) shouldUseWrappedTmpl(vcsHost models.VCSHostType, output string) bool {
|
||||
if m.DisableMarkdownFolding {
|
||||
return false
|
||||
}
|
||||
|
||||
// Bitbucket Cloud and Server don't support the folding markdown syntax.
|
||||
if vcsHost == models.BitbucketServer || vcsHost == models.BitbucketCloud {
|
||||
return false
|
||||
|
||||
@@ -734,6 +734,24 @@ $$$
|
||||
}
|
||||
}
|
||||
|
||||
// Test that if folding is disabled that it's not used.
|
||||
func TestRenderProjectResults_DisableFolding(t *testing.T) {
|
||||
mr := events.MarkdownRenderer{
|
||||
DisableMarkdownFolding: true,
|
||||
}
|
||||
|
||||
rendered := mr.Render(events.CommandResult{
|
||||
ProjectResults: []models.ProjectResult{
|
||||
{
|
||||
RepoRelDir: ".",
|
||||
Workspace: "default",
|
||||
Error: errors.New(strings.Repeat("line\n", 13)),
|
||||
},
|
||||
},
|
||||
}, models.PlanCommand, "log", false, models.Github)
|
||||
Equals(t, false, strings.Contains(rendered, "<details>"))
|
||||
}
|
||||
|
||||
// Test that if the output is longer than 12 lines, it gets wrapped on the right
|
||||
// VCS hosts during an error.
|
||||
func TestRenderProjectResults_WrappedErr(t *testing.T) {
|
||||
|
||||
@@ -231,7 +231,9 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) {
|
||||
markdownRenderer := &events.MarkdownRenderer{
|
||||
GitlabSupportsCommonMark: gitlabClient.SupportsCommonMark(),
|
||||
DisableApplyAll: userConfig.DisableApplyAll,
|
||||
DisableMarkdownFolding: userConfig.DisableMarkdownFolding,
|
||||
}
|
||||
|
||||
boltdb, err := db.New(userConfig.DataDir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -23,6 +23,7 @@ type UserConfig struct {
|
||||
CheckoutStrategy string `mapstructure:"checkout-strategy"`
|
||||
DataDir string `mapstructure:"data-dir"`
|
||||
DisableApplyAll bool `mapstructure:"disable-apply-all"`
|
||||
DisableMarkdownFolding bool `mapstructure:"disable-markdown-folding"`
|
||||
GithubHostname string `mapstructure:"gh-hostname"`
|
||||
GithubToken string `mapstructure:"gh-token"`
|
||||
GithubUser string `mapstructure:"gh-user"`
|
||||
|
||||
Reference in New Issue
Block a user