Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added flag --silence-fork-pr-errors #885

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const (
RepoWhitelistFlag = "repo-whitelist"
RequireApprovalFlag = "require-approval"
RequireMergeableFlag = "require-mergeable"
SilenceForkPRErrorsFlag = "silence-fork-pr-errors"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great! just need to update the tests in server_test.go look for each instance of the whitelist flag and then put your flag in there too

Copy link
Contributor Author

@kinghrothgar kinghrothgar Dec 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I'm missing it, it doesn't look like SilenceWhitelistErrorsFlag is tested in server_test.go. I can add tests for both Silence flags if you would like.

SilenceWhitelistErrorsFlag = "silence-whitelist-errors"
SlackTokenFlag = "slack-token"
SSLCertFileFlag = "ssl-cert-file"
Expand Down Expand Up @@ -247,6 +248,10 @@ var boolFlags = map[string]boolFlag{
defaultValue: false,
hidden: true,
},
SilenceForkPRErrorsFlag: {
description: "Silences the posting of fork pull requests not allowed error comments.",
defaultValue: false,
},
SilenceWhitelistErrorsFlag: {
description: "Silences the posting of whitelist error comments.",
defaultValue: false,
Expand Down Expand Up @@ -420,11 +425,12 @@ func (s *ServerCmd) run() error {

// Config looks good. Start the server.
server, err := s.ServerCreator.NewServer(userConfig, server.Config{
AllowForkPRsFlag: AllowForkPRsFlag,
AtlantisURLFlag: AtlantisURLFlag,
AtlantisVersion: s.AtlantisVersion,
DefaultTFVersionFlag: DefaultTFVersionFlag,
RepoConfigJSONFlag: RepoConfigJSONFlag,
AllowForkPRsFlag: AllowForkPRsFlag,
AtlantisURLFlag: AtlantisURLFlag,
AtlantisVersion: s.AtlantisVersion,
DefaultTFVersionFlag: DefaultTFVersionFlag,
RepoConfigJSONFlag: RepoConfigJSONFlag,
SilenceForkPRErrorsFlag: SilenceForkPRErrorsFlag,
})
if err != nil {
return errors.Wrap(err, "initializing server")
Expand Down
4 changes: 4 additions & 0 deletions cmd/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,8 @@ func TestExecute_Flags(t *testing.T) {
cmd.RepoWhitelistFlag: "github.com/runatlantis/atlantis",
cmd.RequireApprovalFlag: true,
cmd.RequireMergeableFlag: true,
cmd.SilenceForkPRErrorsFlag: true,
cmd.SilenceWhitelistErrorsFlag: true,
cmd.SlackTokenFlag: "slack-token",
cmd.SSLCertFileFlag: "cert-file",
cmd.SSLKeyFileFlag: "key-file",
Expand Down Expand Up @@ -551,6 +553,8 @@ func TestExecute_Flags(t *testing.T) {
Equals(t, "github.com/runatlantis/atlantis", passedConfig.RepoWhitelist)
Equals(t, true, passedConfig.RequireApproval)
Equals(t, true, passedConfig.RequireMergeable)
Equals(t, true, passedConfig.SilenceForkPRErrors)
Equals(t, true, passedConfig.SilenceWhitelistErrors)
Equals(t, "slack-token", passedConfig.SlackToken)
Equals(t, "cert-file", passedConfig.SSLCertFile)
Equals(t, "key-file", passedConfig.SSLKeyFile)
Expand Down
9 changes: 2 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/runatlantis/atlantis
go 1.13

require (
git.apache.org/thrift.git v0.12.0 // indirect
github.com/Masterminds/semver v1.4.2 // indirect
github.com/Masterminds/sprig v2.15.0+incompatible
github.com/aokoli/goutils v1.0.1 // indirect
Expand All @@ -23,7 +22,6 @@ require (
github.com/google/uuid v0.0.0-20161128191214-064e2069ce9c // indirect
github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f // indirect
github.com/gorilla/mux v1.6.2
github.com/grpc-ecosystem/grpc-gateway v1.6.2 // indirect
github.com/hashicorp/go-getter v1.4.0
github.com/hashicorp/go-version v1.2.0
github.com/hashicorp/hcl v0.0.0-20170914154624-68e816d1c783 // indirect
Expand All @@ -36,17 +34,15 @@ require (
github.com/microcosm-cc/bluemonday v1.0.1
github.com/mitchellh/colorstring v0.0.0-20150917214807-8631ce90f286
github.com/mitchellh/go-homedir v1.0.0
github.com/mitchellh/gox v1.0.1 // indirect
github.com/mitchellh/mapstructure v0.0.0-20170523030023-d0303fe80992 // indirect
github.com/mohae/deepcopy v0.0.0-20170603005431-491d3605edfb
github.com/nlopes/slack v0.1.0
github.com/onsi/ginkgo v1.9.0 // indirect
github.com/openzipkin/zipkin-go v0.1.3 // indirect
github.com/pelletier/go-buffruneio v0.2.0 // indirect
github.com/pelletier/go-toml v1.0.0 // indirect
github.com/petergtz/pegomock v2.5.0+incompatible
github.com/petergtz/pegomock v2.7.0+incompatible
github.com/pkg/errors v0.8.0
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829 // indirect
github.com/sirupsen/logrus v1.2.0 // indirect
github.com/spf13/afero v0.0.0-20170901052352-ee1bd8ee15a1 // indirect
github.com/spf13/cast v1.1.0 // indirect
github.com/spf13/cobra v0.0.0-20170905172051-b78744579491
Expand All @@ -57,7 +53,6 @@ require (
github.com/urfave/cli v1.20.0
github.com/urfave/negroni v0.2.0
github.com/xanzy/go-gitlab v0.22.2-0.20191127083556-16a492660b8c
golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d // indirect
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5
golang.org/x/net v0.0.0-20191126235420-ef20fe5d7933 // indirect
golang.org/x/oauth2 v0.0.0-20191122200657-5d9234df094c // indirect
Expand Down
Loading