From da981cbb46033dde037e285d8bac2a1deff95cc0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Aug 2021 17:09:44 -0400 Subject: [PATCH 01/53] build(deps): bump github.com/xanzy/go-gitlab from 0.50.1 to 0.50.2 (#1746) Bumps [github.com/xanzy/go-gitlab](https://github.com/xanzy/go-gitlab) from 0.50.1 to 0.50.2. - [Release notes](https://github.com/xanzy/go-gitlab/releases) - [Changelog](https://github.com/xanzy/go-gitlab/blob/master/releases_test.go) - [Commits](https://github.com/xanzy/go-gitlab/compare/v0.50.1...v0.50.2) --- updated-dependencies: - dependency-name: github.com/xanzy/go-gitlab dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f43f431aed..cad4147465 100644 --- a/go.mod +++ b/go.mod @@ -52,7 +52,7 @@ require ( github.com/stretchr/testify v1.7.0 github.com/urfave/cli v1.22.5 github.com/urfave/negroni v0.3.0 - github.com/xanzy/go-gitlab v0.50.1 + github.com/xanzy/go-gitlab v0.50.2 github.com/zclconf/go-cty v1.5.1 // indirect go.etcd.io/bbolt v1.3.6 go.uber.org/zap v1.18.1 diff --git a/go.sum b/go.sum index cff2f05e0d..d4b35b5535 100644 --- a/go.sum +++ b/go.sum @@ -405,8 +405,8 @@ github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtX github.com/urfave/negroni v0.3.0 h1:PaXOb61mWeZJxc1Ji2xJjpVg9QfPo0rrB+lHyBxGNSU= github.com/urfave/negroni v0.3.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= -github.com/xanzy/go-gitlab v0.50.1 h1:eH1G0/ZV1j81rhGrtbcePjbM5Ern7mPA4Xjt+yE+2PQ= -github.com/xanzy/go-gitlab v0.50.1/go.mod h1:Q+hQhV508bDPoBijv7YjK/Lvlb4PhVhJdKqXVQrUoAE= +github.com/xanzy/go-gitlab v0.50.2 h1:Qm/um2Jryuqusc6VmN7iZYVTQVzNynzSiuMJDnCU1wE= +github.com/xanzy/go-gitlab v0.50.2/go.mod h1:Q+hQhV508bDPoBijv7YjK/Lvlb4PhVhJdKqXVQrUoAE= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= From 48104ea8dc38f47de807c1710f60921f5236a7c5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 15 Aug 2021 14:48:52 -0400 Subject: [PATCH 02/53] build(deps): bump path-parse from 1.0.5 to 1.0.7 (#1753) Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.5 to 1.0.7. - [Release notes](https://github.com/jbgutierrez/path-parse/releases) - [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7) --- updated-dependencies: - dependency-name: path-parse dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yarn.lock b/yarn.lock index 71b07949e4..1057da8f87 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4207,8 +4207,8 @@ path-key@^2.0.0, path-key@^2.0.1: resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" path-parse@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1" + version "1.0.7" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" path-type@^3.0.0: version "3.0.0" From dd3b33cf5fae44f071050e44be1cc6dd6a39380f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Aug 2021 16:38:05 -0400 Subject: [PATCH 03/53] build(deps): bump go.uber.org/zap from 1.18.1 to 1.19.0 (#1756) Bumps [go.uber.org/zap](https://github.com/uber-go/zap) from 1.18.1 to 1.19.0. - [Release notes](https://github.com/uber-go/zap/releases) - [Changelog](https://github.com/uber-go/zap/blob/master/CHANGELOG.md) - [Commits](https://github.com/uber-go/zap/compare/v1.18.1...v1.19.0) --- updated-dependencies: - dependency-name: go.uber.org/zap dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index cad4147465..1a8883ad3c 100644 --- a/go.mod +++ b/go.mod @@ -55,7 +55,7 @@ require ( github.com/xanzy/go-gitlab v0.50.2 github.com/zclconf/go-cty v1.5.1 // indirect go.etcd.io/bbolt v1.3.6 - go.uber.org/zap v1.18.1 + go.uber.org/zap v1.19.0 golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 gopkg.in/go-playground/assert.v1 v1.2.1 // indirect gopkg.in/go-playground/validator.v9 v9.31.0 diff --git a/go.sum b/go.sum index d4b35b5535..2d4cc3c506 100644 --- a/go.sum +++ b/go.sum @@ -436,8 +436,8 @@ go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= -go.uber.org/zap v1.18.1 h1:CSUJ2mjFszzEWt4CdKISEuChVIXGBn3lAPwkRGyVrc4= -go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= +go.uber.org/zap v1.19.0 h1:mZQZefskPPCMIBCSEH0v2/iUqqLrYtaeqwD6FUGUnFE= +go.uber.org/zap v1.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= From fe31bc6243e5ed271bda21d4854b660e65d11c6c Mon Sep 17 00:00:00 2001 From: Masayuki Morita Date: Wed, 18 Aug 2021 02:23:48 +0900 Subject: [PATCH 04/53] Fix typo (#1754) --- server/core/runtime/cache/version_path.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/core/runtime/cache/version_path.go b/server/core/runtime/cache/version_path.go index c375e503d4..c306d6c7fb 100644 --- a/server/core/runtime/cache/version_path.go +++ b/server/core/runtime/cache/version_path.go @@ -28,7 +28,7 @@ func (s *DefaultDiskLookupKeySerializer) Serialize(key *version.Version) (string return fmt.Sprintf("%s%s", s.binaryName, key.Original()), nil } -// ExecutionVersionDiskLayer is a cache layer which attempts to find the the version on disk, +// ExecutionVersionDiskLayer is a cache layer which attempts to find the version on disk, // before calling the configured loading function. type ExecutionVersionDiskLayer struct { versionRootDir models.FilePath From 01b871850926a44712d38f846945b4d6910047c8 Mon Sep 17 00:00:00 2001 From: David Haven Date: Wed, 18 Aug 2021 06:02:01 +0100 Subject: [PATCH 05/53] allow user to pass gh-app-key directly instead of filename (#1706) * allow user to pass gh-app-key directly instead of filename * start fixing tests * fix make test * update website with info about new flag * Apply suggestions from code review Co-authored-by: Roberto Hidalgo Co-authored-by: Roberto Hidalgo --- cmd/server.go | 24 ++++++++++++++----- cmd/server_test.go | 25 ++++++++++++++++---- runatlantis.io/docs/access-credentials.md | 2 +- runatlantis.io/docs/server-configuration.md | 10 ++++++++ server/events/github_app_working_dir_test.go | 7 +----- server/events/vcs/github_credentials.go | 6 ++--- server/events/vcs/github_credentials_test.go | 17 ++----------- server/server.go | 17 +++++++++++-- server/user_config.go | 3 ++- 9 files changed, 73 insertions(+), 38 deletions(-) diff --git a/cmd/server.go b/cmd/server.go index 059142d22f..bc344a3c53 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -65,6 +65,7 @@ const ( GHTokenFlag = "gh-token" GHUserFlag = "gh-user" GHAppIDFlag = "gh-app-id" + GHAppKeyFlag = "gh-app-key" GHAppKeyFileFlag = "gh-app-key-file" GHAppSlugFlag = "gh-app-slug" GHOrganizationFlag = "gh-org" @@ -192,6 +193,10 @@ var stringFlags = map[string]stringFlag{ GHTokenFlag: { description: "GitHub token of API user. Can also be specified via the ATLANTIS_GH_TOKEN environment variable.", }, + GHAppKeyFlag: { + description: "The GitHub App's private key", + defaultValue: "", + }, GHAppKeyFileFlag: { description: "A path to a file containing the GitHub App's private key", defaultValue: "", @@ -634,12 +639,19 @@ func (s *ServerCmd) validate(userConfig server.UserConfig) error { // The following combinations are valid. // 1. github user and token set - // 2. gitlab user and token set - // 3. bitbucket user and token set - // 4. azuredevops user and token set - // 5. any combination of the above - vcsErr := fmt.Errorf("--%s/--%s or --%s/--%s or --%s/--%s or --%s/--%s or --%s/--%s must be set", GHUserFlag, GHTokenFlag, GHAppIDFlag, GHAppKeyFileFlag, GitlabUserFlag, GitlabTokenFlag, BitbucketUserFlag, BitbucketTokenFlag, ADUserFlag, ADTokenFlag) - if ((userConfig.GithubUser == "") != (userConfig.GithubToken == "")) || ((userConfig.GithubAppID == 0) != (userConfig.GithubAppKey == "")) || ((userConfig.GitlabUser == "") != (userConfig.GitlabToken == "")) || ((userConfig.BitbucketUser == "") != (userConfig.BitbucketToken == "")) || ((userConfig.AzureDevopsUser == "") != (userConfig.AzureDevopsToken == "")) { + // 2. github app ID and (key file set or key set) + // 3. gitlab user and token set + // 4. bitbucket user and token set + // 5. azuredevops user and token set + // 6. any combination of the above + vcsErr := fmt.Errorf("--%s/--%s or --%s/--%s or --%s/--%s or --%s/--%s or --%s/--%s or --%s/--%s must be set", GHUserFlag, GHTokenFlag, GHAppIDFlag, GHAppKeyFileFlag, GHAppIDFlag, GHAppKeyFlag, GitlabUserFlag, GitlabTokenFlag, BitbucketUserFlag, BitbucketTokenFlag, ADUserFlag, ADTokenFlag) + if ((userConfig.GithubUser == "") != (userConfig.GithubToken == "")) || ((userConfig.GitlabUser == "") != (userConfig.GitlabToken == "")) || ((userConfig.BitbucketUser == "") != (userConfig.BitbucketToken == "")) || ((userConfig.AzureDevopsUser == "") != (userConfig.AzureDevopsToken == "")) { + return vcsErr + } + if (userConfig.GithubAppID != 0) && ((userConfig.GithubAppKey == "") && (userConfig.GithubAppKeyFile == "")) { + return vcsErr + } + if (userConfig.GithubAppID == 0) && ((userConfig.GithubAppKey != "") || (userConfig.GithubAppKeyFile != "")) { return vcsErr } // At this point, we know that there can't be a single user/token without diff --git a/cmd/server_test.go b/cmd/server_test.go index 7d7e4916bb..7e58a25121 100644 --- a/cmd/server_test.go +++ b/cmd/server_test.go @@ -24,6 +24,7 @@ import ( homedir "github.com/mitchellh/go-homedir" "github.com/runatlantis/atlantis/server" + "github.com/runatlantis/atlantis/server/events/vcs/fixtures" "github.com/runatlantis/atlantis/server/logging" . "github.com/runatlantis/atlantis/testing" "github.com/spf13/cobra" @@ -75,6 +76,7 @@ var testFlags = map[string]interface{}{ GHTokenFlag: "token", GHUserFlag: "user", GHAppIDFlag: int64(0), + GHAppKeyFlag: "", GHAppKeyFileFlag: "", GHAppSlugFlag: "atlantis", GHOrganizationFlag: "", @@ -350,7 +352,7 @@ func TestExecute_ValidateSSLConfig(t *testing.T) { } func TestExecute_ValidateVCSConfig(t *testing.T) { - expErr := "--gh-user/--gh-token or --gh-app-id/--gh-app-key-file or --gitlab-user/--gitlab-token or --bitbucket-user/--bitbucket-token or --azuredevops-user/--azuredevops-token must be set" + expErr := "--gh-user/--gh-token or --gh-app-id/--gh-app-key-file or --gh-app-id/--gh-app-key or --gitlab-user/--gitlab-token or --bitbucket-user/--bitbucket-token or --azuredevops-user/--azuredevops-token must be set" cases := []struct { description string flags map[string]interface{} @@ -404,12 +406,19 @@ func TestExecute_ValidateVCSConfig(t *testing.T) { true, }, { - "just github app key set", + "just github app key file set", map[string]interface{}{ GHAppKeyFileFlag: "key.pem", }, true, }, + { + "just github app key set", + map[string]interface{}{ + GHAppKeyFlag: fixtures.GithubPrivateKey, + }, + true, + }, { "just gitlab user set", map[string]interface{}{ @@ -464,13 +473,21 @@ func TestExecute_ValidateVCSConfig(t *testing.T) { false, }, { - "github app and key set and should be successful", + "github app and key file set and should be successful", map[string]interface{}{ GHAppIDFlag: "1", GHAppKeyFileFlag: "key.pem", }, false, }, + { + "github app and key set and should be successful", + map[string]interface{}{ + GHAppIDFlag: "1", + GHAppKeyFlag: fixtures.GithubPrivateKey, + }, + false, + }, { "gitlab user and gitlab token set and should be successful", map[string]interface{}{ @@ -572,7 +589,7 @@ func TestExecute_GithubUser(t *testing.T) { func TestExecute_GithubApp(t *testing.T) { t.Log("Should remove the @ from the github username if it's passed.") c := setup(map[string]interface{}{ - GHAppKeyFileFlag: "key.pem", + GHAppKeyFlag: fixtures.GithubPrivateKey, GHAppIDFlag: "1", RepoAllowlistFlag: "*", }, t) diff --git a/runatlantis.io/docs/access-credentials.md b/runatlantis.io/docs/access-credentials.md index 64fb2ed946..3dcb8c128a 100644 --- a/runatlantis.io/docs/access-credentials.md +++ b/runatlantis.io/docs/access-credentials.md @@ -45,7 +45,7 @@ Available in Atlantis versions **newer** than 0.13.0. - Create a file with the contents of the GitHub App Key, e.g. `atlantis-app-key.pem` - Restart Atlantis with new flags: `atlantis server --gh-app-id --gh-app-key-file atlantis-app-key.pem --gh-webhook-secret --write-git-creds --repo-allowlist 'github.com/your-org/*' --atlantis-url https://$ATLANTIS_HOST`. - NOTE: You can also create a config file instead of using flags. See [Server Configuration](/docs/server-configuration.html#config-file). + NOTE: Instead of using a file for the GitHub App Key you can also pass the key value directly using `--gh-app-key`. You can also create a config file instead of using flags. See [Server Configuration](/docs/server-configuration.html#config-file). ::: warning Only a single installation per GitHub App is supported at the moment. diff --git a/runatlantis.io/docs/server-configuration.md b/runatlantis.io/docs/server-configuration.md index ad6165a855..44e92777d0 100644 --- a/runatlantis.io/docs/server-configuration.md +++ b/runatlantis.io/docs/server-configuration.md @@ -342,6 +342,16 @@ Values are chosen in this order: ``` Path to a GitHub App PEM encoded private key file. If set, GitHub authentication will be performed as [an installation](https://developer.github.com/v3/apps/installations/). +- ### `--gh-app-key` + ```bash + atlantis server --gh-app-key="-----BEGIN RSA PRIVATE KEY-----(...)" + ``` + The PEM encoded private key for the GitHub App. + + ::: warning SECURITY WARNING + The contents of the private key will be visible by anyone that can run `ps` or look at the shell history of the machine where Atlantis is running. Use `--gh-app-key-file` to mitigate that risk. + ::: + * ### `--gitlab-hostname` ```bash atlantis server --gitlab-hostname="my.gitlab.enterprise.com" diff --git a/server/events/github_app_working_dir_test.go b/server/events/github_app_working_dir_test.go index 25dd64da7d..46f6bac5bd 100644 --- a/server/events/github_app_working_dir_test.go +++ b/server/events/github_app_working_dir_test.go @@ -31,11 +31,6 @@ func TestClone_GithubAppNoneExisting(t *testing.T) { TestingOverrideHeadCloneURL: fmt.Sprintf("file://%s", repoDir), } - tmpDir, cleanup3 := DirStructure(t, map[string]interface{}{ - "key.pem": fixtures.GithubPrivateKey, - }) - defer cleanup3() - defer disableSSLVerification()() testServer, err := fixtures.GithubAppTestServer(t) Ok(t, err) @@ -43,7 +38,7 @@ func TestClone_GithubAppNoneExisting(t *testing.T) { gwd := &events.GithubAppWorkingDir{ WorkingDir: wd, Credentials: &vcs.GithubAppCredentials{ - KeyPath: fmt.Sprintf("%v/key.pem", tmpDir), + Key: []byte(fixtures.GithubPrivateKey), AppID: 1, Hostname: testServer, }, diff --git a/server/events/vcs/github_credentials.go b/server/events/vcs/github_credentials.go index dc18457e00..5c27eadea8 100644 --- a/server/events/vcs/github_credentials.go +++ b/server/events/vcs/github_credentials.go @@ -68,7 +68,7 @@ func (c *GithubUserCredentials) GetToken() (string, error) { // GithubAppCredentials implements GithubCredentials for github app installation token flow. type GithubAppCredentials struct { AppID int64 - KeyPath string + Key []byte Hostname string apiURL *url.URL installationID int64 @@ -128,7 +128,7 @@ func (c *GithubAppCredentials) getInstallationID() (int64, error) { tr := http.DefaultTransport // A non-installation transport - t, err := ghinstallation.NewAppsTransportKeyFromFile(tr, c.AppID, c.KeyPath) + t, err := ghinstallation.NewAppsTransport(tr, c.AppID, c.Key) if err != nil { return 0, err } @@ -163,7 +163,7 @@ func (c *GithubAppCredentials) transport() (*ghinstallation.Transport, error) { } tr := http.DefaultTransport - itr, err := ghinstallation.NewKeyFromFile(tr, c.AppID, installationID, c.KeyPath) + itr, err := ghinstallation.New(tr, c.AppID, installationID, c.Key) if err == nil { apiURL := c.getAPIURL() itr.BaseURL = strings.TrimSuffix(apiURL.String(), "/") diff --git a/server/events/vcs/github_credentials_test.go b/server/events/vcs/github_credentials_test.go index 7de0c98f4f..a85d8d2d95 100644 --- a/server/events/vcs/github_credentials_test.go +++ b/server/events/vcs/github_credentials_test.go @@ -1,7 +1,6 @@ package vcs_test import ( - "fmt" "testing" "github.com/runatlantis/atlantis/server/events/vcs" @@ -21,15 +20,9 @@ func TestGithubClient_GetUser_AppSlug(t *testing.T) { tempSecrets, err := anonClient.ExchangeCode("good-code") Ok(t, err) - tmpDir, cleanup := DirStructure(t, map[string]interface{}{ - "key.pem": tempSecrets.Key, - }) - defer cleanup() - keyPath := fmt.Sprintf("%v/key.pem", tmpDir) - appCreds := &vcs.GithubAppCredentials{ AppID: tempSecrets.ID, - KeyPath: keyPath, + Key: []byte(fixtures.GithubPrivateKey), Hostname: testServer, AppSlug: "some-app", } @@ -51,15 +44,9 @@ func TestGithubClient_AppAuthentication(t *testing.T) { tempSecrets, err := anonClient.ExchangeCode("good-code") Ok(t, err) - tmpDir, cleanup := DirStructure(t, map[string]interface{}{ - "key.pem": tempSecrets.Key, - }) - defer cleanup() - keyPath := fmt.Sprintf("%v/key.pem", tmpDir) - appCreds := &vcs.GithubAppCredentials{ AppID: tempSecrets.ID, - KeyPath: keyPath, + Key: []byte(fixtures.GithubPrivateKey), Hostname: testServer, } _, err = vcs.NewGithubClient(testServer, appCreds, logging.NewNoopLogger(t)) diff --git a/server/server.go b/server/server.go index 3d511c9a63..fd90e15daa 100644 --- a/server/server.go +++ b/server/server.go @@ -20,6 +20,7 @@ import ( "encoding/json" "flag" "fmt" + "io/ioutil" "log" "net/http" "net/url" @@ -156,10 +157,22 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) { User: userConfig.GithubUser, Token: userConfig.GithubToken, } - } else if userConfig.GithubAppID != 0 { + } else if userConfig.GithubAppID != 0 && userConfig.GithubAppKeyFile != "" { + privateKey, err := ioutil.ReadFile(userConfig.GithubAppKeyFile) + if err != nil { + return nil, err + } + githubCredentials = &vcs.GithubAppCredentials{ + AppID: userConfig.GithubAppID, + Key: privateKey, + Hostname: userConfig.GithubHostname, + AppSlug: userConfig.GithubAppSlug, + } + githubAppEnabled = true + } else if userConfig.GithubAppID != 0 && userConfig.GithubAppKey != "" { githubCredentials = &vcs.GithubAppCredentials{ AppID: userConfig.GithubAppID, - KeyPath: userConfig.GithubAppKey, + Key: []byte(userConfig.GithubAppKey), Hostname: userConfig.GithubHostname, AppSlug: userConfig.GithubAppSlug, } diff --git a/server/user_config.go b/server/user_config.go index 5354203fe7..c1ef18fcc9 100644 --- a/server/user_config.go +++ b/server/user_config.go @@ -36,7 +36,8 @@ type UserConfig struct { GithubWebhookSecret string `mapstructure:"gh-webhook-secret"` GithubOrg string `mapstructure:"gh-org"` GithubAppID int64 `mapstructure:"gh-app-id"` - GithubAppKey string `mapstructure:"gh-app-key-file"` + GithubAppKey string `mapstructure:"gh-app-key"` + GithubAppKeyFile string `mapstructure:"gh-app-key-file"` GithubAppSlug string `mapstructure:"gh-app-slug"` GitlabHostname string `mapstructure:"gitlab-hostname"` GitlabToken string `mapstructure:"gitlab-token"` From 9b5f9e181ad1e23be60c98ee209c1c111e31c94b Mon Sep 17 00:00:00 2001 From: rui Date: Wed, 18 Aug 2021 19:03:45 -0400 Subject: [PATCH 06/53] deps: tf 1.0.5 (#1765) Signed-off-by: Rui Chen --- .circleci/config.yml | 2 +- Dockerfile | 2 +- testing/Dockerfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 43264a4c20..e9f6bee2b3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,7 +16,7 @@ jobs: # We do this instead of setting --default-tf-version because setting # that flag starts the download asynchronously so we'd have a race # condition. - TERRAFORM_VERSION: 1.0.4 + TERRAFORM_VERSION: 1.0.5 steps: - checkout - run: make build-service diff --git a/Dockerfile b/Dockerfile index 57fd6efccd..35fe3cf006 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM ghcr.io/runatlantis/atlantis-base:2021.06.22 # install terraform binaries -ENV DEFAULT_TERRAFORM_VERSION=1.0.4 +ENV DEFAULT_TERRAFORM_VERSION=1.0.5 # In the official Atlantis image we only have the latest of each Terraform version. RUN AVAILABLE_TERRAFORM_VERSIONS="0.8.8 0.9.11 0.10.8 0.11.15 0.12.31 0.13.7 0.14.11 0.15.5 ${DEFAULT_TERRAFORM_VERSION}" && \ diff --git a/testing/Dockerfile b/testing/Dockerfile index eec716662a..ae1c78bbb2 100644 --- a/testing/Dockerfile +++ b/testing/Dockerfile @@ -5,7 +5,7 @@ FROM circleci/golang:1.16 # Install Terraform -ENV TERRAFORM_VERSION=1.0.4 +ENV TERRAFORM_VERSION=1.0.5 RUN curl -LOks https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip && \ sudo mkdir -p /usr/local/bin/tf/versions/${TERRAFORM_VERSION} && \ sudo unzip terraform_${TERRAFORM_VERSION}_linux_amd64.zip -d /usr/local/bin/tf/versions/${TERRAFORM_VERSION} && \ From 0d6cc493c8e7b36160cd7fdb5df4c3502f884b8d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 20 Aug 2021 18:35:06 -0400 Subject: [PATCH 07/53] build(deps): bump github.com/xanzy/go-gitlab from 0.50.2 to 0.50.3 (#1757) Bumps [github.com/xanzy/go-gitlab](https://github.com/xanzy/go-gitlab) from 0.50.2 to 0.50.3. - [Release notes](https://github.com/xanzy/go-gitlab/releases) - [Changelog](https://github.com/xanzy/go-gitlab/blob/master/releases_test.go) - [Commits](https://github.com/xanzy/go-gitlab/compare/v0.50.2...v0.50.3) --- updated-dependencies: - dependency-name: github.com/xanzy/go-gitlab dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 1a8883ad3c..6d05d16206 100644 --- a/go.mod +++ b/go.mod @@ -52,7 +52,7 @@ require ( github.com/stretchr/testify v1.7.0 github.com/urfave/cli v1.22.5 github.com/urfave/negroni v0.3.0 - github.com/xanzy/go-gitlab v0.50.2 + github.com/xanzy/go-gitlab v0.50.3 github.com/zclconf/go-cty v1.5.1 // indirect go.etcd.io/bbolt v1.3.6 go.uber.org/zap v1.19.0 diff --git a/go.sum b/go.sum index 2d4cc3c506..30d0653a7e 100644 --- a/go.sum +++ b/go.sum @@ -405,8 +405,8 @@ github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtX github.com/urfave/negroni v0.3.0 h1:PaXOb61mWeZJxc1Ji2xJjpVg9QfPo0rrB+lHyBxGNSU= github.com/urfave/negroni v0.3.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= -github.com/xanzy/go-gitlab v0.50.2 h1:Qm/um2Jryuqusc6VmN7iZYVTQVzNynzSiuMJDnCU1wE= -github.com/xanzy/go-gitlab v0.50.2/go.mod h1:Q+hQhV508bDPoBijv7YjK/Lvlb4PhVhJdKqXVQrUoAE= +github.com/xanzy/go-gitlab v0.50.3 h1:M7ncgNhCN4jaFNyXxarJhCLa9Qi6fdmCxFFhMTQPZiY= +github.com/xanzy/go-gitlab v0.50.3/go.mod h1:Q+hQhV508bDPoBijv7YjK/Lvlb4PhVhJdKqXVQrUoAE= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= From 89236d8e5483c73968ad1973e6682f6a251a4db1 Mon Sep 17 00:00:00 2001 From: Enoch Lo Date: Mon, 30 Aug 2021 14:01:52 -0700 Subject: [PATCH 08/53] Add flag to enable markdown diff formatting (#1751) --- cmd/server.go | 5 + cmd/server_test.go | 1 + runatlantis.io/docs/server-configuration.md | 10 +- server/events/markdown_renderer.go | 48 ++-- server/events/markdown_renderer_test.go | 280 ++++++++++++++++++++ server/events/models/models.go | 11 + server/events/project_command_builder.go | 1 + server/server.go | 1 + server/user_config.go | 1 + 9 files changed, 335 insertions(+), 23 deletions(-) diff --git a/cmd/server.go b/cmd/server.go index bc344a3c53..cd869dbd0f 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -61,6 +61,7 @@ const ( DisableRepoLockingFlag = "disable-repo-locking" EnablePolicyChecksFlag = "enable-policy-checks" EnableRegExpCmdFlag = "enable-regexp-cmd" + EnableDiffMarkdownFormat = "enable-diff-markdown-format" GHHostnameFlag = "gh-hostname" GHTokenFlag = "gh-token" GHUserFlag = "gh-user" @@ -321,6 +322,10 @@ var boolFlags = map[string]boolFlag{ description: "Enable Atlantis to use regular expressions on plan/apply commands when \"-p\" flag is passed with it.", defaultValue: false, }, + EnableDiffMarkdownFormat: { + description: "Enable Atlantis to format Terraform plan output into a markdown-diff friendly format for color-coding purposes.", + defaultValue: false, + }, AllowDraftPRs: { description: "Enable autoplan for Github Draft Pull Requests", defaultValue: false, diff --git a/cmd/server_test.go b/cmd/server_test.go index 7e58a25121..388c79541c 100644 --- a/cmd/server_test.go +++ b/cmd/server_test.go @@ -108,6 +108,7 @@ var testFlags = map[string]interface{}{ DisableAutoplanFlag: true, EnablePolicyChecksFlag: false, EnableRegExpCmdFlag: false, + EnableDiffMarkdownFormat: false, } func TestExecute_Defaults(t *testing.T) { diff --git a/runatlantis.io/docs/server-configuration.md b/runatlantis.io/docs/server-configuration.md index 44e92777d0..34487bc534 100644 --- a/runatlantis.io/docs/server-configuration.md +++ b/runatlantis.io/docs/server-configuration.md @@ -52,7 +52,7 @@ Values are chosen in this order: atlantis server --allow-draft-prs ``` Respond to pull requests from draft prs. Defaults to `false`. - + * ### `--allow-fork-prs` ```bash atlantis server --allow-fork-prs @@ -274,6 +274,14 @@ Values are chosen in this order: The command `atlantis apply -p .*` will bypass the restriction and run apply on every projects ::: +* ### `--enable-diff-markdown-format` + ```bash + atlantis server --enable-diff-markdown-format + ``` + Enable Atlantis to format Terraform plan output into a markdown-diff friendly format for color-coding purposes. + + Useful to enable for use with Github. + * ### `--gh-hostname` ```bash atlantis server --gh-hostname="my.github.enterprise.com" diff --git a/server/events/markdown_renderer.go b/server/events/markdown_renderer.go index 55d86dbee8..36e7a0c680 100644 --- a/server/events/markdown_renderer.go +++ b/server/events/markdown_renderer.go @@ -44,17 +44,19 @@ type MarkdownRenderer struct { DisableApply bool DisableMarkdownFolding bool DisableRepoLocking bool + EnableDiffMarkdownFormat bool } // commonData is data that all responses have. type commonData struct { - Command string - Verbose bool - Log string - PlansDeleted bool - DisableApplyAll bool - DisableApply bool - DisableRepoLocking bool + Command string + Verbose bool + Log string + PlansDeleted bool + DisableApplyAll bool + DisableApply bool + DisableRepoLocking bool + EnableDiffMarkdownFormat bool } // errData is data about an error response. @@ -77,10 +79,11 @@ type resultData struct { type planSuccessData struct { models.PlanSuccess - PlanSummary string - PlanWasDeleted bool - DisableApply bool - DisableRepoLocking bool + PlanSummary string + PlanWasDeleted bool + DisableApply bool + DisableRepoLocking bool + EnableDiffMarkdownFormat bool } type policyCheckSuccessData struct { @@ -99,13 +102,14 @@ type projectResultTmplData struct { func (m *MarkdownRenderer) Render(res CommandResult, cmdName models.CommandName, log string, verbose bool, vcsHost models.VCSHostType) string { commandStr := strings.Title(strings.Replace(cmdName.String(), "_", " ", -1)) common := commonData{ - Command: commandStr, - Verbose: verbose, - Log: log, - PlansDeleted: res.PlansDeleted, - DisableApplyAll: m.DisableApplyAll || m.DisableApply, - DisableApply: m.DisableApply, - DisableRepoLocking: m.DisableRepoLocking, + Command: commandStr, + Verbose: verbose, + Log: log, + PlansDeleted: res.PlansDeleted, + DisableApplyAll: m.DisableApplyAll || m.DisableApply, + DisableApply: m.DisableApply, + DisableRepoLocking: m.DisableRepoLocking, + EnableDiffMarkdownFormat: m.EnableDiffMarkdownFormat, } if res.Error != nil { return m.renderTemplate(unwrappedErrWithLogTmpl, errData{res.Error.Error(), common}) @@ -150,9 +154,9 @@ func (m *MarkdownRenderer) renderProjectResults(results []models.ProjectResult, }) } else if result.PlanSuccess != nil { if m.shouldUseWrappedTmpl(vcsHost, result.PlanSuccess.TerraformOutput) { - resultData.Rendered = m.renderTemplate(planSuccessWrappedTmpl, planSuccessData{PlanSuccess: *result.PlanSuccess, PlanSummary: result.PlanSuccess.Summary(), PlanWasDeleted: common.PlansDeleted, DisableApply: common.DisableApply, DisableRepoLocking: common.DisableRepoLocking}) + resultData.Rendered = m.renderTemplate(planSuccessWrappedTmpl, planSuccessData{PlanSuccess: *result.PlanSuccess, PlanSummary: result.PlanSuccess.Summary(), PlanWasDeleted: common.PlansDeleted, DisableApply: common.DisableApply, DisableRepoLocking: common.DisableRepoLocking, EnableDiffMarkdownFormat: common.EnableDiffMarkdownFormat}) } else { - resultData.Rendered = m.renderTemplate(planSuccessUnwrappedTmpl, planSuccessData{PlanSuccess: *result.PlanSuccess, PlanWasDeleted: common.PlansDeleted, DisableApply: common.DisableApply, DisableRepoLocking: common.DisableRepoLocking}) + resultData.Rendered = m.renderTemplate(planSuccessUnwrappedTmpl, planSuccessData{PlanSuccess: *result.PlanSuccess, PlanWasDeleted: common.PlansDeleted, DisableApply: common.DisableApply, DisableRepoLocking: common.DisableRepoLocking, EnableDiffMarkdownFormat: common.EnableDiffMarkdownFormat}) } numPlanSuccesses++ } else if result.PolicyCheckSuccess != nil { @@ -300,14 +304,14 @@ var multiProjectVersionTmpl = template.Must(template.New("").Funcs(sprig.TxtFunc logTmpl)) var planSuccessUnwrappedTmpl = template.Must(template.New("").Parse( "```diff\n" + - "{{.TerraformOutput}}\n" + + "{{ if .EnableDiffMarkdownFormat }}{{.DiffMarkdownFormattedTerraformOutput}}{{else}}{{.TerraformOutput}}{{end}}\n" + "```\n\n" + planNextSteps + "{{ if .HasDiverged }}\n\n:warning: The branch we're merging into is ahead, it is recommended to pull new commits first.{{end}}")) var planSuccessWrappedTmpl = template.Must(template.New("").Parse( "
Show Output\n\n" + "```diff\n" + - "{{.TerraformOutput}}\n" + + "{{ if .EnableDiffMarkdownFormat }}{{.DiffMarkdownFormattedTerraformOutput}}{{else}}{{.TerraformOutput}}{{end}}\n" + "```\n\n" + planNextSteps + "\n" + "
" + "\n" + diff --git a/server/events/markdown_renderer_test.go b/server/events/markdown_renderer_test.go index c9fca18218..0679a700b6 100644 --- a/server/events/markdown_renderer_test.go +++ b/server/events/markdown_renderer_test.go @@ -2068,3 +2068,283 @@ $$$ }) } } + +func TestRenderProjectResultsWithEnableDiffMarkdownFormat(t *testing.T) { + tfOutput := `An execution plan has been generated and is shown below. +Resource actions are indicated with the following symbols: +~ update in-place +-/+ destroy and then create replacement + +Terraform will perform the following actions: + + # module.redacted.aws_instance.redacted must be replaced +-/+ resource "aws_instance" "redacted" { + ~ ami = "ami-redacted" -> "ami-redacted" # forces replacement + ~ arn = "arn:aws:ec2:us-east-1:redacted:instance/i-redacted" -> (known after apply) + ~ associate_public_ip_address = false -> (known after apply) + availability_zone = "us-east-1b" + ~ cpu_core_count = 4 -> (known after apply) + ~ cpu_threads_per_core = 2 -> (known after apply) + - disable_api_termination = false -> null + - ebs_optimized = false -> null + get_password_data = false + - hibernation = false -> null + + host_id = (known after apply) + iam_instance_profile = "remote_redacted_profile" + ~ id = "i-redacted" -> (known after apply) + ~ instance_state = "running" -> (known after apply) + instance_type = "c5.2xlarge" + ~ ipv6_address_count = 0 -> (known after apply) + ~ ipv6_addresses = [] -> (known after apply) + key_name = "RedactedRedactedRedacted" + - monitoring = false -> null + + outpost_arn = (known after apply) + + password_data = (known after apply) + + placement_group = (known after apply) + ~ primary_network_interface_id = "eni-redacted" -> (known after apply) + ~ private_dns = "ip-redacted.ec2.internal" -> (known after apply) + ~ private_ip = "redacted" -> (known after apply) + + public_dns = (known after apply) + + public_ip = (known after apply) + ~ secondary_private_ips = [] -> (known after apply) + ~ security_groups = [] -> (known after apply) + source_dest_check = true + subnet_id = "subnet-redacted" + tags = { + "Name" = "redacted-redacted" + } + ~ tenancy = "default" -> (known after apply) + user_data = "redacted" + ~ volume_tags = {} -> (known after apply) + vpc_security_group_ids = [ + "sg-redactedsecuritygroup", + ] + + + ebs_block_device { + + delete_on_termination = (known after apply) + + device_name = (known after apply) + + encrypted = (known after apply) + + iops = (known after apply) + + kms_key_id = (known after apply) + + snapshot_id = (known after apply) + + volume_id = (known after apply) + + volume_size = (known after apply) + + volume_type = (known after apply) + } + + + ephemeral_block_device { + + device_name = (known after apply) + + no_device = (known after apply) + + virtual_name = (known after apply) + } + + ~ metadata_options { + ~ http_endpoint = "enabled" -> (known after apply) + ~ http_put_response_hop_limit = 1 -> (known after apply) + ~ http_tokens = "optional" -> (known after apply) + } + + + network_interface { + + delete_on_termination = (known after apply) + + device_index = (known after apply) + + network_interface_id = (known after apply) + } + + ~ root_block_device { + ~ delete_on_termination = true -> (known after apply) + ~ device_name = "/dev/sda1" -> (known after apply) + ~ encrypted = false -> (known after apply) + ~ iops = 600 -> (known after apply) + + kms_key_id = (known after apply) + ~ volume_id = "vol-redacted" -> (known after apply) + ~ volume_size = 200 -> (known after apply) + ~ volume_type = "gp2" -> (known after apply) + } + } + + # module.redacted.aws_route53_record.redacted_record will be updated in-place +~ resource "aws_route53_record" "redacted_record" { + fqdn = "redacted.redacted.redacted.io" + id = "redacted_redacted.redacted.redacted.io_A" + name = "redacted.redacted.redacted.io" + ~ records = [ + - "redacted", + ] -> (known after apply) + ttl = 300 + type = "A" + zone_id = "redacted" + } + +Plan: 1 to add, 1 to change, 1 to destroy. +` + cases := []struct { + Description string + Command models.CommandName + ProjectResults []models.ProjectResult + VCSHost models.VCSHostType + Expected string + }{ + { + "single successful plan with diff markdown formatted", + models.PlanCommand, + []models.ProjectResult{ + { + PlanSuccess: &models.PlanSuccess{ + TerraformOutput: tfOutput, + LockURL: "lock-url", + RePlanCmd: "atlantis plan -d path -w workspace", + ApplyCmd: "atlantis apply -d path -w workspace", + }, + Workspace: "workspace", + RepoRelDir: "path", + }, + }, + models.Github, + `Ran Plan for dir: $path$ workspace: $workspace$ + +
Show Output + +$$$diff +An execution plan has been generated and is shown below. +Resource actions are indicated with the following symbols: +! update in-place +-/+ destroy and then create replacement + +Terraform will perform the following actions: + + # module.redacted.aws_instance.redacted must be replaced +-/+ resource "aws_instance" "redacted" { +! ami = "ami-redacted" -> "ami-redacted" # forces replacement +! arn = "arn:aws:ec2:us-east-1:redacted:instance/i-redacted" -> (known after apply) +! associate_public_ip_address = false -> (known after apply) + availability_zone = "us-east-1b" +! cpu_core_count = 4 -> (known after apply) +! cpu_threads_per_core = 2 -> (known after apply) +- disable_api_termination = false -> null +- ebs_optimized = false -> null + get_password_data = false +- hibernation = false -> null ++ host_id = (known after apply) + iam_instance_profile = "remote_redacted_profile" +! id = "i-redacted" -> (known after apply) +! instance_state = "running" -> (known after apply) + instance_type = "c5.2xlarge" +! ipv6_address_count = 0 -> (known after apply) +! ipv6_addresses = [] -> (known after apply) + key_name = "RedactedRedactedRedacted" +- monitoring = false -> null ++ outpost_arn = (known after apply) ++ password_data = (known after apply) ++ placement_group = (known after apply) +! primary_network_interface_id = "eni-redacted" -> (known after apply) +! private_dns = "ip-redacted.ec2.internal" -> (known after apply) +! private_ip = "redacted" -> (known after apply) ++ public_dns = (known after apply) ++ public_ip = (known after apply) +! secondary_private_ips = [] -> (known after apply) +! security_groups = [] -> (known after apply) + source_dest_check = true + subnet_id = "subnet-redacted" + tags = { + "Name" = "redacted-redacted" + } +! tenancy = "default" -> (known after apply) + user_data = "redacted" +! volume_tags = {} -> (known after apply) + vpc_security_group_ids = [ + "sg-redactedsecuritygroup", + ] + ++ ebs_block_device { ++ delete_on_termination = (known after apply) ++ device_name = (known after apply) ++ encrypted = (known after apply) ++ iops = (known after apply) ++ kms_key_id = (known after apply) ++ snapshot_id = (known after apply) ++ volume_id = (known after apply) ++ volume_size = (known after apply) ++ volume_type = (known after apply) + } + ++ ephemeral_block_device { ++ device_name = (known after apply) ++ no_device = (known after apply) ++ virtual_name = (known after apply) + } + +! metadata_options { +! http_endpoint = "enabled" -> (known after apply) +! http_put_response_hop_limit = 1 -> (known after apply) +! http_tokens = "optional" -> (known after apply) + } + ++ network_interface { ++ delete_on_termination = (known after apply) ++ device_index = (known after apply) ++ network_interface_id = (known after apply) + } + +! root_block_device { +! delete_on_termination = true -> (known after apply) +! device_name = "/dev/sda1" -> (known after apply) +! encrypted = false -> (known after apply) +! iops = 600 -> (known after apply) ++ kms_key_id = (known after apply) +! volume_id = "vol-redacted" -> (known after apply) +! volume_size = 200 -> (known after apply) +! volume_type = "gp2" -> (known after apply) + } + } + + # module.redacted.aws_route53_record.redacted_record will be updated in-place +! resource "aws_route53_record" "redacted_record" { + fqdn = "redacted.redacted.redacted.io" + id = "redacted_redacted.redacted.redacted.io_A" + name = "redacted.redacted.redacted.io" +! records = [ +- "redacted", + ] -> (known after apply) + ttl = 300 + type = "A" + zone_id = "redacted" + } + +Plan: 1 to add, 1 to change, 1 to destroy. + +$$$ + +* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) +* :repeat: To **plan** this project again, comment: + * $atlantis plan -d path -w workspace$ +
+Plan: 1 to add, 1 to change, 1 to destroy. + + +`, + }, + } + r := events.MarkdownRenderer{ + DisableApplyAll: true, + DisableApply: true, + EnableDiffMarkdownFormat: true, + } + for _, c := range cases { + t.Run(c.Description, func(t *testing.T) { + res := events.CommandResult{ + ProjectResults: c.ProjectResults, + } + for _, verbose := range []bool{true, false} { + t.Run(c.Description, func(t *testing.T) { + s := r.Render(res, c.Command, "log", verbose, c.VCSHost) + expWithBackticks := strings.Replace(c.Expected, "$", "`", -1) + if !verbose { + Equals(t, expWithBackticks, s) + } else { + Equals(t, expWithBackticks+"
Log\n

\n\n```\nlog```\n

\n", s) + } + }) + } + }) + } +} diff --git a/server/events/models/models.go b/server/events/models/models.go index 8d2baf9e55..fb66ac1230 100644 --- a/server/events/models/models.go +++ b/server/events/models/models.go @@ -518,6 +518,17 @@ func (p *PlanSuccess) Summary() string { return note + r.FindString(p.TerraformOutput) } +// DiffMarkdownFormattedTerraformOutput formats the Terraform output to match diff markdown format +func (p PlanSuccess) DiffMarkdownFormattedTerraformOutput() string { + diffKeywordRegex := regexp.MustCompile(`(?m)^( +)([-+~])`) + diffTildeRegex := regexp.MustCompile(`(?m)^~`) + + formattedTerraformOutput := diffKeywordRegex.ReplaceAllString(p.TerraformOutput, "$2$1") + formattedTerraformOutput = diffTildeRegex.ReplaceAllString(formattedTerraformOutput, "!") + + return formattedTerraformOutput +} + // PolicyCheckSuccess is the result of a successful policy check run. type PolicyCheckSuccess struct { // PolicyCheckOutput is the output from policy check binary(conftest|opa) diff --git a/server/events/project_command_builder.go b/server/events/project_command_builder.go index da44a86b91..03f744162f 100644 --- a/server/events/project_command_builder.go +++ b/server/events/project_command_builder.go @@ -117,6 +117,7 @@ type DefaultProjectCommandBuilder struct { SkipCloneNoChanges bool EnableRegExpCmd bool AutoplanFileList string + EnableDiffMarkdownFormat bool } // See ProjectCommandBuilder.BuildAutoplanCommands. diff --git a/server/server.go b/server/server.go index fd90e15daa..88e84cda7c 100644 --- a/server/server.go +++ b/server/server.go @@ -309,6 +309,7 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) { DisableMarkdownFolding: userConfig.DisableMarkdownFolding, DisableApply: userConfig.DisableApply, DisableRepoLocking: userConfig.DisableRepoLocking, + EnableDiffMarkdownFormat: userConfig.EnableDiffMarkdownFormat, } boltdb, err := db.New(userConfig.DataDir) diff --git a/server/user_config.go b/server/user_config.go index c1ef18fcc9..4875ad7671 100644 --- a/server/user_config.go +++ b/server/user_config.go @@ -30,6 +30,7 @@ type UserConfig struct { DisableRepoLocking bool `mapstructure:"disable-repo-locking"` EnablePolicyChecksFlag bool `mapstructure:"enable-policy-checks"` EnableRegExpCmd bool `mapstructure:"enable-regexp-cmd"` + EnableDiffMarkdownFormat bool `mapstructure:"enable-diff-markdown-format"` GithubHostname string `mapstructure:"gh-hostname"` GithubToken string `mapstructure:"gh-token"` GithubUser string `mapstructure:"gh-user"` From 42940421a2be870df2ba42795020d3d2633f1904 Mon Sep 17 00:00:00 2001 From: Ken Kaizu Date: Tue, 31 Aug 2021 06:39:04 +0900 Subject: [PATCH 09/53] Split Gitlab Server comments if over max length (#1755) --- server/events/vcs/gitlab_client.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/server/events/vcs/gitlab_client.go b/server/events/vcs/gitlab_client.go index d3f32373c1..07e26df88d 100644 --- a/server/events/vcs/gitlab_client.go +++ b/server/events/vcs/gitlab_client.go @@ -34,6 +34,10 @@ import ( gitlab "github.com/xanzy/go-gitlab" ) +// gitlabMaxCommentLength is the maximum number of chars allowed by Gitlab in a +// single comment. +const gitlabMaxCommentLength = 1000000 + type GitlabClient struct { Client *gitlab.Client // Version is set to the server version. @@ -146,8 +150,17 @@ func (g *GitlabClient) GetModifiedFiles(repo models.Repo, pull models.PullReques // CreateComment creates a comment on the merge request. func (g *GitlabClient) CreateComment(repo models.Repo, pullNum int, comment string, command string) error { - _, _, err := g.Client.Notes.CreateMergeRequestNote(repo.FullName, pullNum, &gitlab.CreateMergeRequestNoteOptions{Body: gitlab.String(comment)}) - return err + sepEnd := "\n```\n" + + "\n
\n\n**Warning**: Output length greater than max comment size. Continued in next comment." + sepStart := "Continued from previous comment.\n
Show Output\n\n" + + "```diff\n" + comments := common.SplitComment(comment, gitlabMaxCommentLength, sepEnd, sepStart) + for _, c := range comments { + if _, _, err := g.Client.Notes.CreateMergeRequestNote(repo.FullName, pullNum, &gitlab.CreateMergeRequestNoteOptions{Body: gitlab.String(c)}); err != nil { + return err + } + } + return nil } func (g *GitlabClient) HidePrevCommandComments(repo models.Repo, pullNum int, command string) error { From fe54ddd25291cd53979c14de43878a137997fe29 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Aug 2021 14:39:47 -0700 Subject: [PATCH 10/53] build(deps): bump github.com/hashicorp/go-getter from 1.5.6 to 1.5.7 (#1758) Bumps [github.com/hashicorp/go-getter](https://github.com/hashicorp/go-getter) from 1.5.6 to 1.5.7. - [Release notes](https://github.com/hashicorp/go-getter/releases) - [Changelog](https://github.com/hashicorp/go-getter/blob/main/.goreleaser.yml) - [Commits](https://github.com/hashicorp/go-getter/compare/v1.5.6...v1.5.7) --- updated-dependencies: - dependency-name: github.com/hashicorp/go-getter dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6d05d16206..61c3023cb3 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/google/uuid v1.1.2-0.20200519141726-cb32006e483f // indirect github.com/gorilla/mux v1.8.0 github.com/gorilla/websocket v1.4.2 // indirect - github.com/hashicorp/go-getter v1.5.6 + github.com/hashicorp/go-getter v1.5.7 github.com/hashicorp/go-version v1.3.0 github.com/hashicorp/hcl/v2 v2.6.0 // indirect github.com/hashicorp/terraform-config-inspect v0.0.0-20200806211835-c481b8bfa41e diff --git a/go.sum b/go.sum index 30d0653a7e..996b50bba4 100644 --- a/go.sum +++ b/go.sum @@ -216,8 +216,8 @@ github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-getter v1.5.6 h1:G3YZUoFzwAqDS3dSQKwfVfxM1f/wxrM5LdRP9Sne8z0= -github.com/hashicorp/go-getter v1.5.6/go.mod h1:BrrV/1clo8cCYu6mxvboYg+KutTiFnXjMEgDD8+i7ZI= +github.com/hashicorp/go-getter v1.5.7 h1:HBLsom8eGHLxj78ta+/MVSyct8KWG4B4z6lhBA4vJcg= +github.com/hashicorp/go-getter v1.5.7/go.mod h1:BrrV/1clo8cCYu6mxvboYg+KutTiFnXjMEgDD8+i7ZI= github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxCsHI= github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= From c0faa16f6eed77f9da3caabe9cee47030d768d0d Mon Sep 17 00:00:00 2001 From: Muhammad Kamran Azeem Date: Mon, 30 Aug 2021 23:40:16 +0200 Subject: [PATCH 11/53] Fixed instructions for adding Webhook under Gitlab (#1737) The instructions incorrectly asked to visit "Settings->Integrations" , whereas the correct instruction is to visit "Settings->Webhooks". This PR fixes the error. --- runatlantis.io/guide/testing-locally.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runatlantis.io/guide/testing-locally.md b/runatlantis.io/guide/testing-locally.md index 8b6f390c17..cbe371473b 100644 --- a/runatlantis.io/guide/testing-locally.md +++ b/runatlantis.io/guide/testing-locally.md @@ -86,7 +86,7 @@ Take the URL that ngrok output and create a webhook in your GitHub, GitLab or Bi Expand
  • Go to your repo's home page
  • -
  • Click Settings > Integrations in the sidebar
  • +
  • Click Settings > Webhooks in the sidebar
  • set URL to your ngrok url with /events at the end. Ex. https://c5004d84.ngrok.io/events
  • double-check you added /events to the end of your URL.
  • set Secret Token to your random string
  • From 7ce8cef3078e1d216a072ea4f5404cc0d82a3284 Mon Sep 17 00:00:00 2001 From: Gerald Barker Date: Mon, 30 Aug 2021 22:53:49 +0100 Subject: [PATCH 12/53] Fix regression - Delete .terraform.lock.hcl if it was created by terraform init (#1701) * Delete .terraform.lock.hcl prior to terraform init if it is not staged * Changes suggeted by reviewer --- .../events/events_controller_e2e_test.go | 169 +++++++++++++++++- .../null_provider_lockfile_old_version | 20 +++ .../exp-output-autoplan.txt | 48 +++++ .../simple-with-lockfile/exp-output-plan.txt | 48 +++++ .../test-repos/simple-with-lockfile/main.tf | 18 ++ server/core/runtime/init_step_runner.go | 30 ++-- server/core/runtime/init_step_runner_test.go | 73 +++++++- server/events/mocks/mock_working_dir.go | 85 +++++++++ server/events/runtime/common/common.go | 30 +++- server/events/runtime/common/common_test.go | 61 +++++++ 10 files changed, 557 insertions(+), 25 deletions(-) create mode 100644 server/controllers/events/testfixtures/null_provider_lockfile_old_version create mode 100644 server/controllers/events/testfixtures/test-repos/simple-with-lockfile/exp-output-autoplan.txt create mode 100644 server/controllers/events/testfixtures/test-repos/simple-with-lockfile/exp-output-plan.txt create mode 100644 server/controllers/events/testfixtures/test-repos/simple-with-lockfile/main.tf diff --git a/server/controllers/events/events_controller_e2e_test.go b/server/controllers/events/events_controller_e2e_test.go index 601e03bc15..baba9f05c5 100644 --- a/server/controllers/events/events_controller_e2e_test.go +++ b/server/controllers/events/events_controller_e2e_test.go @@ -67,8 +67,8 @@ func TestGitHubWorkflow(t *testing.T) { if testing.Short() { t.SkipNow() } - // Ensure we have >= TF 0.12 locally. - ensureRunning012(t) + // Ensure we have >= TF 0.14 locally. + ensureRunning014(t) cases := []struct { Description string @@ -456,12 +456,165 @@ func TestGitHubWorkflow(t *testing.T) { } } +func TestSimlpleWorkflow_terraformLockFile(t *testing.T) { + + if testing.Short() { + t.SkipNow() + } + // Ensure we have >= TF 0.14 locally. + ensureRunning014(t) + + cases := []struct { + Description string + // RepoDir is relative to testfixtures/test-repos. + RepoDir string + // ModifiedFiles are the list of files that have been modified in this + // pull request. + ModifiedFiles []string + // ExpAutoplan is true if we expect Atlantis to autoplan. + ExpAutoplan bool + // Comments are what our mock user writes to the pull request. + Comments []string + // ExpReplies is a list of files containing the expected replies that + // Atlantis writes to the pull request in order. A reply from a parallel operation + // will be matched using a substring check. + ExpReplies [][]string + // LockFileTracked deterims if the `.terraform.lock.hcl` file is tracked in git + // if this is true we dont expect the lockfile to be modified by terraform init + // if false we expect the lock file to be updated + LockFileTracked bool + }{ + { + Description: "simple with plan comment lockfile staged", + RepoDir: "simple-with-lockfile", + ModifiedFiles: []string{"main.tf"}, + ExpAutoplan: true, + Comments: []string{ + "atlantis plan", + }, + ExpReplies: [][]string{ + {"exp-output-autoplan.txt"}, + {"exp-output-plan.txt"}, + }, + LockFileTracked: true, + }, + { + Description: "simple with plan comment lockfile not staged", + RepoDir: "simple-with-lockfile", + ModifiedFiles: []string{"main.tf"}, + Comments: []string{ + "atlantis plan", + }, + ExpReplies: [][]string{ + {"exp-output-autoplan.txt"}, + {"exp-output-plan.txt"}, + }, + LockFileTracked: false, + }, + } + for _, c := range cases { + t.Run(c.Description, func(t *testing.T) { + RegisterMockTestingT(t) + + // reset userConfig + userConfig = server.UserConfig{} + userConfig.DisableApply = true + + ctrl, vcsClient, githubGetter, atlantisWorkspace := setupE2E(t, c.RepoDir) + // Set the repo to be cloned through the testing backdoor. + repoDir, headSHA, cleanup := initializeRepo(t, c.RepoDir) + defer cleanup() + + oldLockFilePath, err := filepath.Abs(filepath.Join("testfixtures", "null_provider_lockfile_old_version")) + Ok(t, err) + oldLockFileContent, err := ioutil.ReadFile(oldLockFilePath) + Ok(t, err) + + if c.LockFileTracked { + runCmd(t, "", "cp", oldLockFilePath, fmt.Sprintf("%s/.terraform.lock.hcl", repoDir)) + runCmd(t, repoDir, "git", "add", ".terraform.lock.hcl") + runCmd(t, repoDir, "git", "commit", "-am", "stage .terraform.lock.hcl") + } + + atlantisWorkspace.TestingOverrideHeadCloneURL = fmt.Sprintf("file://%s", repoDir) + + // Setup test dependencies. + w := httptest.NewRecorder() + When(githubGetter.GetPullRequest(AnyRepo(), AnyInt())).ThenReturn(GitHubPullRequestParsed(headSHA), nil) + When(vcsClient.GetModifiedFiles(AnyRepo(), matchers.AnyModelsPullRequest())).ThenReturn(c.ModifiedFiles, nil) + + // First, send the open pull request event which triggers autoplan. + pullOpenedReq := GitHubPullRequestOpenedEvent(t, headSHA) + ctrl.Post(w, pullOpenedReq) + ResponseContains(t, w, 200, "Processing...") + + // check lock file content + actualLockFileContent, err := ioutil.ReadFile(fmt.Sprintf("%s/repos/runatlantis/atlantis-tests/2/default/.terraform.lock.hcl", atlantisWorkspace.DataDir)) + Ok(t, err) + if c.LockFileTracked { + if string(oldLockFileContent) != string(actualLockFileContent) { + t.Error("Expected terraform.lock.hcl file not to be different as it has been staged") + t.FailNow() + } + } else { + if string(oldLockFileContent) == string(actualLockFileContent) { + t.Error("Expected terraform.lock.hcl file to be different as it should have been updated") + t.FailNow() + } + } + + if !c.LockFileTracked { + // replace the lock file generated by the previous init to simulate + // dependcies needing updating in a latter plan + runCmd(t, "", "cp", oldLockFilePath, fmt.Sprintf("%s/repos/runatlantis/atlantis-tests/2/default/.terraform.lock.hcl", atlantisWorkspace.DataDir)) + } + + // Now send any other comments. + for _, comment := range c.Comments { + commentReq := GitHubCommentEvent(t, comment) + w = httptest.NewRecorder() + ctrl.Post(w, commentReq) + ResponseContains(t, w, 200, "Processing...") + } + + // check lock file content + actualLockFileContent, err = ioutil.ReadFile(fmt.Sprintf("%s/repos/runatlantis/atlantis-tests/2/default/.terraform.lock.hcl", atlantisWorkspace.DataDir)) + Ok(t, err) + if c.LockFileTracked { + if string(oldLockFileContent) != string(actualLockFileContent) { + t.Error("Expected terraform.lock.hcl file not to be different as it has been staged") + t.FailNow() + } + } else { + if string(oldLockFileContent) == string(actualLockFileContent) { + t.Error("Expected terraform.lock.hcl file to be different as it should have been updated") + t.FailNow() + } + } + + // Let's verify the pre-workflow hook was called for each comment including the pull request opened event + mockPreWorkflowHookRunner.VerifyWasCalled(Times(2)).Run(runtimematchers.AnyModelsPreWorkflowHookCommandContext(), EqString("some dummy command"), AnyString()) + + // Now we're ready to verify Atlantis made all the comments back (or + // replies) that we expect. We expect each plan to have 1 comment, + // and apply have 1 for each comment plus one for the locks deleted at the + // end. + + _, _, actReplies, _ := vcsClient.VerifyWasCalled(Times(2)).CreateComment(AnyRepo(), AnyInt(), AnyString(), AnyString()).GetAllCapturedArguments() + Assert(t, len(c.ExpReplies) == len(actReplies), "missing expected replies, got %d but expected %d", len(actReplies), len(c.ExpReplies)) + for i, expReply := range c.ExpReplies { + assertCommentEquals(t, expReply, actReplies[i], c.RepoDir, false) + } + }) + } +} + func TestGitHubWorkflowWithPolicyCheck(t *testing.T) { if testing.Short() { t.SkipNow() } - // Ensure we have >= TF 0.12 locally. - ensureRunning012(t) + // Ensure we have >= TF 0.14 locally. + ensureRunning014(t) // Ensure we have >= Conftest 0.21 locally. ensureRunningConftest(t) @@ -1135,11 +1288,11 @@ func ensureRunningConftest(t *testing.T) { } } -// Will fail test if terraform isn't in path and isn't version >= 0.12 -func ensureRunning012(t *testing.T) { +// Will fail test if terraform isn't in path and isn't version >= 0.14 +func ensureRunning014(t *testing.T) { localPath, err := exec.LookPath("terraform") if err != nil { - t.Log("terraform >= 0.12 must be installed to run this test") + t.Log("terraform >= 0.14 must be installed to run this test") t.FailNow() } versionOutBytes, err := exec.Command(localPath, "version").Output() // #nosec @@ -1155,7 +1308,7 @@ func ensureRunning012(t *testing.T) { } localVersion, err := version.NewVersion(match[1]) Ok(t, err) - minVersion, err := version.NewVersion("0.12.0") + minVersion, err := version.NewVersion("0.14.0") Ok(t, err) if localVersion.LessThan(minVersion) { t.Logf("must have terraform version >= %s, you have %s", minVersion, localVersion) diff --git a/server/controllers/events/testfixtures/null_provider_lockfile_old_version b/server/controllers/events/testfixtures/null_provider_lockfile_old_version new file mode 100644 index 0000000000..09c858af04 --- /dev/null +++ b/server/controllers/events/testfixtures/null_provider_lockfile_old_version @@ -0,0 +1,20 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/null" { + version = "3.0.0" + constraints = "3.0.0" + hashes = [ + "h1:ysHGBhBNkIiJLEpthB/IVCLpA1Qoncp3KbCTFGFZTO0=", + "zh:05fb7eab469324c97e9b73a61d2ece6f91de4e9b493e573bfeda0f2077bc3a4c", + "zh:1688aa91885a395c4ae67636d411475d0b831e422e005dcf02eedacaafac3bb4", + "zh:24a0b1292e3a474f57c483a7a4512d797e041bc9c2fbaac42fe12e86a7fb5a3c", + "zh:2fc951bd0d1b9b23427acc93be09b6909d72871e464088171da60fbee4fdde03", + "zh:6db825759425599a326385a68acc6be2d9ba0d7d6ef587191d0cdc6daef9ac63", + "zh:85985763d02618993c32c294072cc6ec51f1692b803cb506fcfedca9d40eaec9", + "zh:a53186599c57058be1509f904da512342cfdc5d808efdaf02dec15f0f3cb039a", + "zh:c2e07b49b6efa676bdc7b00c06333ea1792a983a5720f9e2233db27323d2707c", + "zh:cdc8fe1096103cf5374751e2e8408ec4abd2eb67d5a1c5151fe2c7ecfd525bef", + "zh:dbdef21df0c012b0d08776f3d4f34eb0f2f229adfde07ff252a119e52c0f65b7", + ] +} diff --git a/server/controllers/events/testfixtures/test-repos/simple-with-lockfile/exp-output-autoplan.txt b/server/controllers/events/testfixtures/test-repos/simple-with-lockfile/exp-output-autoplan.txt new file mode 100644 index 0000000000..b301024b0c --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/simple-with-lockfile/exp-output-autoplan.txt @@ -0,0 +1,48 @@ +Ran Plan for dir: `.` workspace: `default` + +
    Show Output + +```diff + +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++ create + +Terraform will perform the following actions: + + # null_resource.simple[0] will be created ++ resource "null_resource" "simple" { + + id = (known after apply) + } + + # null_resource.simple2 will be created ++ resource "null_resource" "simple2" { + + id = (known after apply) + } + + # null_resource.simple3 will be created ++ resource "null_resource" "simple3" { + + id = (known after apply) + } + +Plan: 3 to add, 0 to change, 0 to destroy. + +Changes to Outputs: ++ var = "default" ++ workspace = "default" + +``` + +* :arrow_forward: To **apply** this plan, comment: + * `atlantis apply -d .` +* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) +* :repeat: To **plan** this project again, comment: + * `atlantis plan -d .` +
    +Plan: 3 to add, 0 to change, 0 to destroy. + +--- +* :fast_forward: To **apply** all unapplied plans from this pull request, comment: + * `atlantis apply` +* :put_litter_in_its_place: To delete all plans and locks for the PR, comment: + * `atlantis unlock` diff --git a/server/controllers/events/testfixtures/test-repos/simple-with-lockfile/exp-output-plan.txt b/server/controllers/events/testfixtures/test-repos/simple-with-lockfile/exp-output-plan.txt new file mode 100644 index 0000000000..b301024b0c --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/simple-with-lockfile/exp-output-plan.txt @@ -0,0 +1,48 @@ +Ran Plan for dir: `.` workspace: `default` + +
    Show Output + +```diff + +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++ create + +Terraform will perform the following actions: + + # null_resource.simple[0] will be created ++ resource "null_resource" "simple" { + + id = (known after apply) + } + + # null_resource.simple2 will be created ++ resource "null_resource" "simple2" { + + id = (known after apply) + } + + # null_resource.simple3 will be created ++ resource "null_resource" "simple3" { + + id = (known after apply) + } + +Plan: 3 to add, 0 to change, 0 to destroy. + +Changes to Outputs: ++ var = "default" ++ workspace = "default" + +``` + +* :arrow_forward: To **apply** this plan, comment: + * `atlantis apply -d .` +* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) +* :repeat: To **plan** this project again, comment: + * `atlantis plan -d .` +
    +Plan: 3 to add, 0 to change, 0 to destroy. + +--- +* :fast_forward: To **apply** all unapplied plans from this pull request, comment: + * `atlantis apply` +* :put_litter_in_its_place: To delete all plans and locks for the PR, comment: + * `atlantis unlock` diff --git a/server/controllers/events/testfixtures/test-repos/simple-with-lockfile/main.tf b/server/controllers/events/testfixtures/test-repos/simple-with-lockfile/main.tf new file mode 100644 index 0000000000..2394ee4a7a --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/simple-with-lockfile/main.tf @@ -0,0 +1,18 @@ +resource "null_resource" "simple" { + count = 1 +} + +resource "null_resource" "simple2" {} +resource "null_resource" "simple3" {} + +variable "var" { + default = "default" +} + +output "var" { + value = var.var +} + +output "workspace" { + value = terraform.workspace +} diff --git a/server/core/runtime/init_step_runner.go b/server/core/runtime/init_step_runner.go index 6d85758238..77e1daad47 100644 --- a/server/core/runtime/init_step_runner.go +++ b/server/core/runtime/init_step_runner.go @@ -16,6 +16,24 @@ type InitStepRunner struct { } func (i *InitStepRunner) Run(ctx models.ProjectCommandContext, extraArgs []string, path string, envs map[string]string) (string, error) { + lockFileName := ".terraform.lock.hcl" + terraformLockfilePath := filepath.Join(path, lockFileName) + terraformLockFileTracked, err := common.IsFileTracked(path, lockFileName) + if err != nil { + ctx.Log.Warn("Error checking if %s is tracked in %s", lockFileName, path) + + } + // If .terraform.lock.hcl is not tracked in git and it exists prior to init + // delete it as it probably has been created by a previous run of + // terraform init + if common.FileExists(terraformLockfilePath) && !terraformLockFileTracked { + ctx.Log.Debug("Deleting `%s` that was generated by previous terraform init", terraformLockfilePath) + delErr := os.Remove(terraformLockfilePath) + if delErr != nil { + ctx.Log.Info("Error Deleting `%s`", lockFileName) + } + } + tfVersion := i.DefaultTFVersion if ctx.TerraformVersion != nil { tfVersion = ctx.TerraformVersion @@ -33,8 +51,7 @@ func (i *InitStepRunner) Run(ctx models.ProjectCommandContext, extraArgs []strin terraformInitArgs = append(terraformInitArgs, "-no-color") - lockfilePath := filepath.Join(path, ".terraform.lock.hcl") - if MustConstraint("< 0.14.0").Check(tfVersion) || fileDoesNotExists(lockfilePath) { + if MustConstraint("< 0.14.0").Check(tfVersion) || !common.FileExists(terraformLockfilePath) { terraformInitArgs = append(terraformInitArgs, "-upgrade") } @@ -50,12 +67,3 @@ func (i *InitStepRunner) Run(ctx models.ProjectCommandContext, extraArgs []strin } return "", nil } - -func fileDoesNotExists(name string) bool { - if _, err := os.Stat(name); err != nil { - if os.IsNotExist(err) { - return true - } - } - return false -} diff --git a/server/core/runtime/init_step_runner_test.go b/server/core/runtime/init_step_runner_test.go index fff48728c0..496f13f7a7 100644 --- a/server/core/runtime/init_step_runner_test.go +++ b/server/core/runtime/init_step_runner_test.go @@ -2,7 +2,9 @@ package runtime_test import ( "io/ioutil" + "os/exec" "path/filepath" + "strings" "testing" version "github.com/hashicorp/go-version" @@ -98,12 +100,17 @@ func TestRun_ShowInitOutputOnError(t *testing.T) { Equals(t, "output", output) } -func TestRun_InitOmitsUpgradeFlagIfLockFilePresent(t *testing.T) { - tmpDir, cleanup := TempDir(t) +func TestRun_InitOmitsUpgradeFlagIfLockFileTracked(t *testing.T) { + // Initialize the git repo. + repoDir, cleanup := initRepo(t) defer cleanup() - lockFilePath := filepath.Join(tmpDir, ".terraform.lock.hcl") + + lockFilePath := filepath.Join(repoDir, ".terraform.lock.hcl") err := ioutil.WriteFile(lockFilePath, nil, 0600) Ok(t, err) + // commit lock file + runCmd(t, repoDir, "git", "add", ".terraform.lock.hcl") + runCmd(t, repoDir, "git", "commit", "-m", "add .terraform.lock.hcl") RegisterMockTestingT(t) terraform := mocks.NewMockClient() @@ -122,13 +129,13 @@ func TestRun_InitOmitsUpgradeFlagIfLockFilePresent(t *testing.T) { Workspace: "workspace", RepoRelDir: ".", Log: logger, - }, []string{"extra", "args"}, tmpDir, map[string]string(nil)) + }, []string{"extra", "args"}, repoDir, map[string]string(nil)) Ok(t, err) // When there is no error, should not return init output to PR. Equals(t, "", output) expectedArgs := []string{"init", "-input=false", "-no-color", "extra", "args"} - terraform.VerifyWasCalledOnce().RunCommandWithVersion(logger, tmpDir, expectedArgs, map[string]string(nil), tfVersion, "workspace") + terraform.VerifyWasCalledOnce().RunCommandWithVersion(logger, repoDir, expectedArgs, map[string]string(nil), tfVersion, "workspace") } func TestRun_InitKeepsUpgradeFlagIfLockFileNotPresent(t *testing.T) { @@ -260,3 +267,59 @@ func TestRun_InitExtraArgsDeDupe(t *testing.T) { }) } } + +func TestRun_InitDeletesLockFileIfPresentAndNotTracked(t *testing.T) { + // Initialize the git repo. + repoDir, cleanup := initRepo(t) + defer cleanup() + + lockFilePath := filepath.Join(repoDir, ".terraform.lock.hcl") + err := ioutil.WriteFile(lockFilePath, nil, 0600) + Ok(t, err) + + RegisterMockTestingT(t) + terraform := mocks.NewMockClient() + + logger := logging.NewNoopLogger(t) + + tfVersion, _ := version.NewVersion("0.14.0") + iso := runtime.InitStepRunner{ + TerraformExecutor: terraform, + DefaultTFVersion: tfVersion, + } + When(terraform.RunCommandWithVersion(logging_matchers.AnyLoggingSimpleLogging(), AnyString(), AnyStringSlice(), matchers2.AnyMapOfStringToString(), matchers2.AnyPtrToGoVersionVersion(), AnyString())). + ThenReturn("output", nil) + + output, err := iso.Run(models.ProjectCommandContext{ + Workspace: "workspace", + RepoRelDir: ".", + Log: logger, + }, []string{"extra", "args"}, repoDir, map[string]string(nil)) + Ok(t, err) + // When there is no error, should not return init output to PR. + Equals(t, "", output) + + expectedArgs := []string{"init", "-input=false", "-no-color", "-upgrade", "extra", "args"} + terraform.VerifyWasCalledOnce().RunCommandWithVersion(logger, repoDir, expectedArgs, map[string]string(nil), tfVersion, "workspace") +} + +func runCmd(t *testing.T, dir string, name string, args ...string) string { + t.Helper() + cpCmd := exec.Command(name, args...) + cpCmd.Dir = dir + cpOut, err := cpCmd.CombinedOutput() + Assert(t, err == nil, "err running %q: %s", strings.Join(append([]string{name}, args...), " "), cpOut) + return string(cpOut) +} + +func initRepo(t *testing.T) (string, func()) { + repoDir, cleanup := TempDir(t) + runCmd(t, repoDir, "git", "init") + runCmd(t, repoDir, "touch", ".gitkeep") + runCmd(t, repoDir, "git", "add", ".gitkeep") + runCmd(t, repoDir, "git", "config", "--local", "user.email", "atlantisbot@runatlantis.io") + runCmd(t, repoDir, "git", "config", "--local", "user.name", "atlantisbot") + runCmd(t, repoDir, "git", "commit", "-m", "initial commit") + runCmd(t, repoDir, "git", "branch", "branch") + return repoDir, cleanup +} diff --git a/server/events/mocks/mock_working_dir.go b/server/events/mocks/mock_working_dir.go index 4e743f8900..d9aca75a20 100644 --- a/server/events/mocks/mock_working_dir.go +++ b/server/events/mocks/mock_working_dir.go @@ -120,6 +120,25 @@ func (mock *MockWorkingDir) DeleteForWorkspace(r models.Repo, p models.PullReque return ret0 } +func (mock *MockWorkingDir) IsFileTracked(log logging.SimpleLogging, cloneDir string, filename string) (bool, error) { + if mock == nil { + panic("mock must not be nil. Use myMock := NewMockWorkingDir().") + } + params := []pegomock.Param{log, cloneDir, filename} + result := pegomock.GetGenericMockFrom(mock).Invoke("IsFileTracked", params, []reflect.Type{reflect.TypeOf((*bool)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()}) + var ret0 bool + var ret1 error + if len(result) != 0 { + if result[0] != nil { + ret0 = result[0].(bool) + } + if result[1] != nil { + ret1 = result[1].(error) + } + } + return ret0, ret1 +} + func (mock *MockWorkingDir) VerifyWasCalledOnce() *VerifierMockWorkingDir { return &VerifierMockWorkingDir{ mock: mock, @@ -231,6 +250,37 @@ func (c *MockWorkingDir_GetWorkingDir_OngoingVerification) GetAllCapturedArgumen return } +func (verifier *VerifierMockWorkingDir) HasDiverged(log logging.SimpleLogging, cloneDir string) *MockWorkingDir_HasDiverged_OngoingVerification { + params := []pegomock.Param{log, cloneDir} + methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "HasDiverged", params, verifier.timeout) + return &MockWorkingDir_HasDiverged_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} +} + +type MockWorkingDir_HasDiverged_OngoingVerification struct { + mock *MockWorkingDir + methodInvocations []pegomock.MethodInvocation +} + +func (c *MockWorkingDir_HasDiverged_OngoingVerification) GetCapturedArguments() (logging.SimpleLogging, string) { + log, cloneDir := c.GetAllCapturedArguments() + return log[len(log)-1], cloneDir[len(cloneDir)-1] +} + +func (c *MockWorkingDir_HasDiverged_OngoingVerification) GetAllCapturedArguments() (_param0 []logging.SimpleLogging, _param1 []string) { + params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations) + if len(params) > 0 { + _param0 = make([]logging.SimpleLogging, len(c.methodInvocations)) + for u, param := range params[0] { + _param0[u] = param.(logging.SimpleLogging) + } + _param1 = make([]string, len(c.methodInvocations)) + for u, param := range params[1] { + _param1[u] = param.(string) + } + } + return +} + func (verifier *VerifierMockWorkingDir) GetPullDir(r models.Repo, p models.PullRequest) *MockWorkingDir_GetPullDir_OngoingVerification { params := []pegomock.Param{r, p} methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "GetPullDir", params, verifier.timeout) @@ -327,3 +377,38 @@ func (c *MockWorkingDir_DeleteForWorkspace_OngoingVerification) GetAllCapturedAr } return } + +func (verifier *VerifierMockWorkingDir) IsFileTracked(log logging.SimpleLogging, cloneDir string, filename string) *MockWorkingDir_IsFileTracked_OngoingVerification { + params := []pegomock.Param{log, cloneDir, filename} + methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "IsFileTracked", params, verifier.timeout) + return &MockWorkingDir_IsFileTracked_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} +} + +type MockWorkingDir_IsFileTracked_OngoingVerification struct { + mock *MockWorkingDir + methodInvocations []pegomock.MethodInvocation +} + +func (c *MockWorkingDir_IsFileTracked_OngoingVerification) GetCapturedArguments() (logging.SimpleLogging, string, string) { + log, cloneDir, filename := c.GetAllCapturedArguments() + return log[len(log)-1], cloneDir[len(cloneDir)-1], filename[len(filename)-1] +} + +func (c *MockWorkingDir_IsFileTracked_OngoingVerification) GetAllCapturedArguments() (_param0 []logging.SimpleLogging, _param1 []string, _param2 []string) { + params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations) + if len(params) > 0 { + _param0 = make([]logging.SimpleLogging, len(c.methodInvocations)) + for u, param := range params[0] { + _param0[u] = param.(logging.SimpleLogging) + } + _param1 = make([]string, len(c.methodInvocations)) + for u, param := range params[1] { + _param1[u] = param.(string) + } + _param2 = make([]string, len(c.methodInvocations)) + for u, param := range params[2] { + _param2[u] = param.(string) + } + } + return +} diff --git a/server/events/runtime/common/common.go b/server/events/runtime/common/common.go index d459e0e043..cc11f30768 100644 --- a/server/events/runtime/common/common.go +++ b/server/events/runtime/common/common.go @@ -1,6 +1,10 @@ package common -import "strings" +import ( + "os" + "os/exec" + "strings" +) // Looks for any argument in commandArgs that has been overridden by an entry in extra args and replaces them // any extraArgs that are not used as overrides are added yo the end of the final string slice @@ -53,6 +57,30 @@ func DeDuplicateExtraArgs(commandArgs []string, extraArgs []string) []string { return finalArgs } +// returns true if a file at the passed path exists +func FileExists(path string) bool { + if _, err := os.Stat(path); err != nil { + if os.IsNotExist(err) { + return false + } + } + return true +} + +// returns true if the given file is tracked by git +func IsFileTracked(cloneDir string, filename string) (bool, error) { + cmd := exec.Command("git", "ls-files", filename) + cmd.Dir = cloneDir + + output, err := cmd.CombinedOutput() + + if err != nil { + return false, err + } + return len(output) > 0, nil + +} + func stringInSlice(stringSlice []string, target string) bool { for _, value := range stringSlice { if value == target { diff --git a/server/events/runtime/common/common_test.go b/server/events/runtime/common/common_test.go index d426eaf0ed..5df4d1a98b 100644 --- a/server/events/runtime/common/common_test.go +++ b/server/events/runtime/common/common_test.go @@ -1,8 +1,12 @@ package common import ( + "os/exec" "reflect" + "strings" "testing" + + . "github.com/runatlantis/atlantis/testing" ) func Test_DeDuplicateExtraArgs(t *testing.T) { @@ -84,3 +88,60 @@ func Test_DeDuplicateExtraArgs(t *testing.T) { }) } } + +func runCmd(t *testing.T, dir string, name string, args ...string) string { + t.Helper() + cpCmd := exec.Command(name, args...) + cpCmd.Dir = dir + cpOut, err := cpCmd.CombinedOutput() + Assert(t, err == nil, "err running %q: %s", strings.Join(append([]string{name}, args...), " "), cpOut) + return string(cpOut) +} + +func initRepo(t *testing.T) (string, func()) { + repoDir, cleanup := TempDir(t) + runCmd(t, repoDir, "git", "init") + runCmd(t, repoDir, "touch", ".gitkeep") + runCmd(t, repoDir, "git", "add", ".gitkeep") + runCmd(t, repoDir, "git", "config", "--local", "user.email", "atlantisbot@runatlantis.io") + runCmd(t, repoDir, "git", "config", "--local", "user.name", "atlantisbot") + runCmd(t, repoDir, "git", "commit", "-m", "initial commit") + runCmd(t, repoDir, "git", "branch", "branch") + return repoDir, cleanup +} + +func TestIsFileTracked(t *testing.T) { + // Initialize the git repo. + repoDir, cleanup := initRepo(t) + defer cleanup() + + // file1 should not be tracked + tracked, err := IsFileTracked(repoDir, "file1") + Ok(t, err) + Equals(t, tracked, false) + + // stage file1 + runCmd(t, repoDir, "touch", "file1") + runCmd(t, repoDir, "git", "add", "file1") + runCmd(t, repoDir, "git", "commit", "-m", "add file1") + + // file1 should be tracked + tracked, err = IsFileTracked(repoDir, "file1") + Ok(t, err) + Equals(t, tracked, true) + + // .terraform.lock.hcl should not be tracked + tracked, err = IsFileTracked(repoDir, ".terraform.lock.hcl") + Ok(t, err) + Equals(t, tracked, false) + + // stage .terraform.lock.hcl + runCmd(t, repoDir, "touch", ".terraform.lock.hcl") + runCmd(t, repoDir, "git", "add", ".terraform.lock.hcl") + runCmd(t, repoDir, "git", "commit", "-m", "add .terraform.lock.hcl") + + // file1 should be tracked + tracked, err = IsFileTracked(repoDir, ".terraform.lock.hcl") + Ok(t, err) + Equals(t, tracked, true) +} From 2600708fba38099bcceba583ace17212c2360e47 Mon Sep 17 00:00:00 2001 From: Masayuki Morita Date: Tue, 31 Aug 2021 07:13:59 +0900 Subject: [PATCH 13/53] Validate base branches in DefaultCommandRunner (#1768) Fixes #1539 The branch matcher feature has been introduced in #1383, but the current implementation was broken and doesn't work at all (#1539). If my understanding is correct, there are two problems: (1) The `GlobalCfg` has a default `Repo` instance which always matches any repositries and branches. Therefore the branch matcher never be functional. (2) Validating base branches in `DefaultPreWorkflowHooksCommandRunner.RunPreHooks()` implicitly assumed that users customize `pre_workflow_hooks`, but the assumption isn't always true because it defaults to empty. For (1), I added a new method `MatchingRepo()` to `GlobalCfg` to check `BranchMatches()` for a single `Repo` instance. For (2), I moved validating branch to `DefaultCommandRunner.validateCtxAndComment()`. Since the method has already validated meta data of pull request, I think it's suitable place to check base branches, but please let me know if there is anywhere more suitable. --- .../events/events_controller_e2e_test.go | 1 + server/events/command_runner.go | 9 +++ server/events/command_runner_test.go | 38 +++++++++++ .../pre_workflow_hooks_command_runner.go | 2 +- server/events/yaml/valid/global_cfg.go | 12 ++++ server/events/yaml/valid/global_cfg_test.go | 63 +++++++++++++++++++ server/server.go | 1 + 7 files changed, 125 insertions(+), 1 deletion(-) diff --git a/server/controllers/events/events_controller_e2e_test.go b/server/controllers/events/events_controller_e2e_test.go index baba9f05c5..fd0c6adfe1 100644 --- a/server/controllers/events/events_controller_e2e_test.go +++ b/server/controllers/events/events_controller_e2e_test.go @@ -1036,6 +1036,7 @@ func setupE2E(t *testing.T, repoDir string) (events_controllers.VCSEventsControl GithubPullGetter: e2eGithubGetter, GitlabMergeRequestGetter: e2eGitlabGetter, Logger: logger, + GlobalCfg: globalCfg, AllowForkPRs: allowForkPRs, AllowForkPRsFlag: "allow-fork-prs", CommentCommandRunnerByCmd: commentCommandRunnerByCmd, diff --git a/server/events/command_runner.go b/server/events/command_runner.go index 24c717a01d..cb15e75eb7 100644 --- a/server/events/command_runner.go +++ b/server/events/command_runner.go @@ -22,6 +22,7 @@ import ( "github.com/pkg/errors" "github.com/runatlantis/atlantis/server/events/models" "github.com/runatlantis/atlantis/server/events/vcs" + "github.com/runatlantis/atlantis/server/events/yaml/valid" "github.com/runatlantis/atlantis/server/logging" "github.com/runatlantis/atlantis/server/recovery" gitlab "github.com/xanzy/go-gitlab" @@ -95,6 +96,7 @@ type DefaultCommandRunner struct { DisableAutoplan bool EventParser EventParsing Logger logging.SimpleLogging + GlobalCfg valid.GlobalCfg // AllowForkPRs controls whether we operate on pull requests from forks. AllowForkPRs bool // ParallelPoolSize controls the size of the wait group used to run @@ -320,6 +322,13 @@ func (c *DefaultCommandRunner) validateCtxAndComment(ctx *CommandContext) bool { } return false } + + repo := c.GlobalCfg.MatchingRepo(ctx.Pull.BaseRepo.ID()) + if !repo.BranchMatches(ctx.Pull.BaseBranch) { + ctx.Log.Info("command was run on a pull request which doesn't match base branches") + // just ignore it to allow us to use any git workflows without malicious intentions. + return false + } return true } diff --git a/server/events/command_runner_test.go b/server/events/command_runner_test.go index a236eb30d0..0184d226e2 100644 --- a/server/events/command_runner_test.go +++ b/server/events/command_runner_test.go @@ -16,6 +16,7 @@ package events_test import ( "errors" "fmt" + "regexp" "strings" "testing" @@ -182,6 +183,8 @@ func setup(t *testing.T) *vcsmocks.MockClient { When(preWorkflowHooksCommandRunner.RunPreHooks(matchers.AnyPtrToEventsCommandContext())).ThenReturn(nil) + globalCfg := valid.NewGlobalCfgFromArgs(valid.GlobalCfgArgs{}) + ch = events.DefaultCommandRunner{ VCSClient: vcsClient, CommentCommandRunnerByCmd: commentCommandRunnerByCmd, @@ -190,6 +193,7 @@ func setup(t *testing.T) *vcsmocks.MockClient { GitlabMergeRequestGetter: gitlabGetter, AzureDevopsPullGetter: azuredevopsGetter, Logger: logger, + GlobalCfg: globalCfg, AllowForkPRs: false, AllowForkPRsFlag: "allow-fork-prs-flag", Drainer: drainer, @@ -404,6 +408,40 @@ func TestRunCommentCommand_ClosedPull(t *testing.T) { vcsClient.VerifyWasCalledOnce().CreateComment(fixtures.GithubRepo, modelPull.Num, "Atlantis commands can't be run on closed pull requests", "") } +func TestRunCommentCommand_MatchedBranch(t *testing.T) { + t.Log("if a command is run on a pull request which matches base branches run plan successfully") + vcsClient := setup(t) + + ch.GlobalCfg.Repos = append(ch.GlobalCfg.Repos, valid.Repo{ + IDRegex: regexp.MustCompile(".*"), + BranchRegex: regexp.MustCompile("^main$"), + }) + var pull github.PullRequest + modelPull := models.PullRequest{BaseRepo: fixtures.GithubRepo, BaseBranch: "main"} + When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(&pull, nil) + When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil) + + ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: models.PlanCommand}) + vcsClient.VerifyWasCalledOnce().CreateComment(fixtures.GithubRepo, modelPull.Num, "Ran Plan for 0 projects:\n\n\n\n", "plan") +} + +func TestRunCommentCommand_UnmatchedBranch(t *testing.T) { + t.Log("if a command is run on a pull request which doesn't match base branches do not comment with error") + vcsClient := setup(t) + + ch.GlobalCfg.Repos = append(ch.GlobalCfg.Repos, valid.Repo{ + IDRegex: regexp.MustCompile(".*"), + BranchRegex: regexp.MustCompile("^main$"), + }) + var pull github.PullRequest + modelPull := models.PullRequest{BaseRepo: fixtures.GithubRepo, BaseBranch: "foo"} + When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(&pull, nil) + When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil) + + ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: models.PlanCommand}) + vcsClient.VerifyWasCalled(Never()).CreateComment(matchers.AnyModelsRepo(), AnyInt(), AnyString(), AnyString()) +} + func TestRunUnlockCommand_VCSComment(t *testing.T) { t.Log("if unlock PR command is run, atlantis should" + " invoke the delete command and comment on PR accordingly") diff --git a/server/events/pre_workflow_hooks_command_runner.go b/server/events/pre_workflow_hooks_command_runner.go index 1f110db1d4..7619fd9a82 100644 --- a/server/events/pre_workflow_hooks_command_runner.go +++ b/server/events/pre_workflow_hooks_command_runner.go @@ -34,7 +34,7 @@ func (w *DefaultPreWorkflowHooksCommandRunner) RunPreHooks( preWorkflowHooks := make([]*valid.PreWorkflowHook, 0) for _, repo := range w.GlobalCfg.Repos { - if repo.IDMatches(baseRepo.ID()) && repo.BranchMatches(pull.BaseBranch) && len(repo.PreWorkflowHooks) > 0 { + if repo.IDMatches(baseRepo.ID()) && len(repo.PreWorkflowHooks) > 0 { preWorkflowHooks = append(preWorkflowHooks, repo.PreWorkflowHooks...) } } diff --git a/server/events/yaml/valid/global_cfg.go b/server/events/yaml/valid/global_cfg.go index c2c4ced7db..81068d11ab 100644 --- a/server/events/yaml/valid/global_cfg.go +++ b/server/events/yaml/valid/global_cfg.go @@ -467,3 +467,15 @@ func (g GlobalCfg) getMatchingCfg(log logging.SimpleLogging, repoID string) (app } return } + +// MatchingRepo returns an instance of Repo which matches a given repoID. +// If multiple repos match, return the last one for consistency with getMatchingCfg. +func (g GlobalCfg) MatchingRepo(repoID string) *Repo { + for i := len(g.Repos) - 1; i >= 0; i-- { + repo := g.Repos[i] + if repo.IDMatches(repoID) { + return &repo + } + } + return nil +} diff --git a/server/events/yaml/valid/global_cfg_test.go b/server/events/yaml/valid/global_cfg_test.go index 475cf7dfa4..f317a81015 100644 --- a/server/events/yaml/valid/global_cfg_test.go +++ b/server/events/yaml/valid/global_cfg_test.go @@ -892,6 +892,69 @@ func TestRepo_BranchMatches(t *testing.T) { Equals(t, false, (valid.Repo{BranchRegex: regexp.MustCompile("release")}).BranchMatches("main")) } +func TestGlobalCfg_MatchingRepo(t *testing.T) { + defaultRepo := valid.Repo{ + IDRegex: regexp.MustCompile(".*"), + BranchRegex: regexp.MustCompile(".*"), + ApplyRequirements: []string{}, + } + repo1 := valid.Repo{ + IDRegex: regexp.MustCompile(".*"), + BranchRegex: regexp.MustCompile("^main$"), + ApplyRequirements: []string{"approved"}, + } + repo2 := valid.Repo{ + ID: "github.com/owner/repo", + BranchRegex: regexp.MustCompile("^master$"), + ApplyRequirements: []string{"approved", "mergeable"}, + } + + cases := map[string]struct { + gCfg valid.GlobalCfg + repoID string + exp *valid.Repo + }{ + "matches to default": { + gCfg: valid.GlobalCfg{ + Repos: []valid.Repo{ + defaultRepo, + repo2, + }, + }, + repoID: "foo", + exp: &defaultRepo, + }, + "matches to IDRegex": { + gCfg: valid.GlobalCfg{ + Repos: []valid.Repo{ + defaultRepo, + repo1, + repo2, + }, + }, + repoID: "foo", + exp: &repo1, + }, + "matches to ID": { + gCfg: valid.GlobalCfg{ + Repos: []valid.Repo{ + defaultRepo, + repo1, + repo2, + }, + }, + repoID: "github.com/owner/repo", + exp: &repo2, + }, + } + + for name, c := range cases { + t.Run(name, func(t *testing.T) { + Equals(t, c.exp, c.gCfg.MatchingRepo(c.repoID)) + }) + } +} + // String is a helper routine that allocates a new string value // to store v and returns a pointer to it. func String(v string) *string { return &v } diff --git a/server/server.go b/server/server.go index 88e84cda7c..5c8324839b 100644 --- a/server/server.go +++ b/server/server.go @@ -600,6 +600,7 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) { CommentCommandRunnerByCmd: commentCommandRunnerByCmd, EventParser: eventParser, Logger: logger, + GlobalCfg: globalCfg, AllowForkPRs: userConfig.AllowForkPRs, AllowForkPRsFlag: config.AllowForkPRsFlag, SilenceForkPRErrors: userConfig.SilenceForkPRErrors, From 317503a071713be01e6f4b99a29d61bd8aef2362 Mon Sep 17 00:00:00 2001 From: rui Date: Mon, 30 Aug 2021 23:19:46 -0400 Subject: [PATCH 14/53] build: bump to use go1.17 (#1766) * build: bump to use go1.17 Signed-off-by: Rui Chen --- .circleci/config.yml | 4 +- .github/workflows/atlantis-image.yml | 2 +- Makefile | 2 +- e2e/go.mod | 8 +++- go.mod | 64 +++++++++++++++++++++++++++- testing/Dockerfile | 2 +- 6 files changed, 75 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e9f6bee2b3..56d247c290 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,7 +10,7 @@ jobs: - run: make check-lint e2e: docker: - - image: circleci/golang:1.16 # If you update this, update it in the Makefile too + - image: circleci/golang:1.17 # If you update this, update it in the Makefile too environment: # This version of TF will be downloaded before Atlantis is started. # We do this instead of setting --default-tf-version because setting @@ -50,7 +50,7 @@ jobs: # Build and push Docker tag. docker_tag: docker: - - image: circleci/golang:1.16 # If you update this, update it in the Makefile too + - image: circleci/golang:1.17 # If you update this, update it in the Makefile too steps: - checkout - run: make build-service diff --git a/.github/workflows/atlantis-image.yml b/.github/workflows/atlantis-image.yml index 7340fd26f2..6b769dd3aa 100644 --- a/.github/workflows/atlantis-image.yml +++ b/.github/workflows/atlantis-image.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: - go-version: 1.16 + go-version: 1.17 - name: Login to Packages Container registry uses: docker/login-action@v1 with: diff --git a/Makefile b/Makefile index d0603f0707..7b06fe573c 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ dist: ## Package up everything in static/ using go-bindata-assetfs so it can be rm -f server/static/bindata_assetfs.go && go-bindata-assetfs -pkg static -prefix server server/static/... && mv bindata_assetfs.go server/static release: ## Create packages for a release - docker run -v $$(pwd):/go/src/github.com/runatlantis/atlantis circleci/golang:1.16 sh -c 'cd /go/src/github.com/runatlantis/atlantis && scripts/binary-release.sh' + docker run -v $$(pwd):/go/src/github.com/runatlantis/atlantis circleci/golang:1.17 sh -c 'cd /go/src/github.com/runatlantis/atlantis && scripts/binary-release.sh' fmt: ## Run goimports (which also formats) goimports -w $$(find . -type f -name '*.go' ! -path "./vendor/*" ! -path "./server/static/bindata_assetfs.go" ! -path "**/mocks/*") diff --git a/e2e/go.mod b/e2e/go.mod index 948cd685b8..fd0c4355a4 100644 --- a/e2e/go.mod +++ b/e2e/go.mod @@ -1,8 +1,14 @@ module github.com/runatlantis/atlantis/e2e -go 1.16 +go 1.17 require ( github.com/google/go-github/v28 v28.0.0 github.com/hashicorp/go-multierror v1.0.0 ) + +require ( + github.com/google/go-querystring v1.0.0 // indirect + github.com/hashicorp/errwrap v1.0.0 // indirect + golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 // indirect +) diff --git a/go.mod b/go.mod index 61c3023cb3..3b72ef27c3 100644 --- a/go.mod +++ b/go.mod @@ -1,64 +1,126 @@ module github.com/runatlantis/atlantis -go 1.16 +go 1.17 replace google.golang.org/grpc => google.golang.org/grpc v1.29.1 require ( + cloud.google.com/go v0.81.0 // indirect + cloud.google.com/go/storage v1.10.0 // indirect github.com/Laisky/graphql v1.0.5 + github.com/Masterminds/goutils v1.1.1 // indirect + github.com/Masterminds/semver/v3 v3.1.1 // indirect github.com/Masterminds/sprig/v3 v3.2.2 github.com/agext/levenshtein v1.2.3 // indirect + github.com/apparentlymart/go-textseg/v12 v12.0.0 // indirect github.com/aws/aws-sdk-go v1.31.15 // indirect + github.com/aymerick/douceur v0.2.0 // indirect + github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bradleyfalzon/ghinstallation v1.1.1 github.com/briandowns/spinner v0.0.0-20170614154858-48dbb65d7bd5 + github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/docker/docker v0.0.0-20180620051407-e2593239d949 github.com/elazarl/go-bindata-assetfs v1.0.1 + github.com/fatih/color v1.7.0 // indirect github.com/flynn-archive/go-shlex v0.0.0-20150515145356-3f9db97f8568 github.com/fsnotify/fsnotify v1.4.10-0.20200417215612-7f4cf4dd2b52 // indirect github.com/go-ozzo/ozzo-validation v0.0.0-20170913164239-85dcd8368eba github.com/go-playground/locales v0.12.1 // indirect github.com/go-playground/universal-translator v0.16.0 // indirect github.com/go-test/deep v1.0.7 + github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/google/go-cmp v0.5.5 // indirect + github.com/google/go-github/v29 v29.0.2 // indirect github.com/google/go-github/v31 v31.0.0 + github.com/google/go-querystring v1.0.0 // indirect github.com/google/uuid v1.1.2-0.20200519141726-cb32006e483f // indirect + github.com/googleapis/gax-go/v2 v2.0.5 // indirect + github.com/gorilla/css v1.0.0 // indirect github.com/gorilla/mux v1.8.0 github.com/gorilla/websocket v1.4.2 // indirect + github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-getter v1.5.7 + github.com/hashicorp/go-retryablehttp v0.6.8 // indirect + github.com/hashicorp/go-safetemp v1.0.0 // indirect github.com/hashicorp/go-version v1.3.0 + github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/hcl/v2 v2.6.0 // indirect github.com/hashicorp/terraform-config-inspect v0.0.0-20200806211835-c481b8bfa41e + github.com/huandu/xstrings v1.3.1 // indirect + github.com/imdario/mergo v0.3.11 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/jmespath/go-jmespath v0.3.1-0.20200310193758-2437e8417af5 // indirect + github.com/jstemmer/go-junit-report v0.9.1 // indirect + github.com/klauspost/compress v1.11.2 // indirect github.com/leodido/go-urn v1.2.0 // indirect github.com/lusis/slack-test v0.0.0-20190426140909-c40012f20018 // indirect + github.com/magiconair/properties v1.8.5 // indirect + github.com/mattn/go-colorable v0.0.9 // indirect + github.com/mattn/go-isatty v0.0.4 // indirect github.com/mcdafydd/go-azuredevops v0.12.0 github.com/microcosm-cc/bluemonday v1.0.15 github.com/mitchellh/colorstring v0.0.0-20150917214807-8631ce90f286 + github.com/mitchellh/copystructure v1.0.0 // indirect github.com/mitchellh/go-homedir v1.1.0 + github.com/mitchellh/go-testing-interface v1.0.0 // indirect + github.com/mitchellh/go-wordwrap v1.0.0 // indirect + github.com/mitchellh/mapstructure v1.4.1 // indirect + github.com/mitchellh/reflectwalk v1.0.0 // indirect github.com/mohae/deepcopy v0.0.0-20170603005431-491d3605edfb github.com/nlopes/slack v0.4.0 github.com/onsi/ginkgo v1.14.0 // indirect + github.com/onsi/gomega v1.10.1 // indirect + github.com/pelletier/go-toml v1.9.3 // indirect github.com/petergtz/pegomock v2.9.0+incompatible github.com/pkg/errors v0.9.1 + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/remeh/sizedwaitgroup v1.0.0 + github.com/russross/blackfriday/v2 v2.0.1 // indirect + github.com/shopspring/decimal v1.2.0 // indirect github.com/shurcooL/githubv4 v0.0.0-20191127044304-8f68eb5628d0 github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f // indirect + github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect github.com/sirupsen/logrus v1.6.1-0.20200528085638-6699a89a232f // indirect + github.com/spf13/afero v1.6.0 // indirect + github.com/spf13/cast v1.3.1 // indirect github.com/spf13/cobra v0.0.0-20170905172051-b78744579491 + github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.8.1 github.com/stretchr/testify v1.7.0 + github.com/subosito/gotenv v1.2.0 // indirect + github.com/ulikunitz/xz v0.5.8 // indirect github.com/urfave/cli v1.22.5 github.com/urfave/negroni v0.3.0 github.com/xanzy/go-gitlab v0.50.3 github.com/zclconf/go-cty v1.5.1 // indirect go.etcd.io/bbolt v1.3.6 + go.opencensus.io v0.23.0 // indirect + go.uber.org/atomic v1.7.0 // indirect + go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.19.0 golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 + golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect + golang.org/x/mod v0.4.2 // indirect + golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect + golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602 // indirect + golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect + golang.org/x/text v0.3.6 // indirect + golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect + golang.org/x/tools v0.1.2 // indirect + golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect + google.golang.org/api v0.44.0 // indirect + google.golang.org/appengine v1.6.7 // indirect + google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect + google.golang.org/grpc v1.38.0 // indirect + google.golang.org/protobuf v1.26.0 // indirect gopkg.in/go-playground/assert.v1 v1.2.1 // indirect gopkg.in/go-playground/validator.v9 v9.31.0 + gopkg.in/ini.v1 v1.62.0 // indirect gopkg.in/yaml.v2 v2.4.0 + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect gotest.tools v2.2.0+incompatible // indirect ) diff --git a/testing/Dockerfile b/testing/Dockerfile index ae1c78bbb2..aacf341032 100644 --- a/testing/Dockerfile +++ b/testing/Dockerfile @@ -2,7 +2,7 @@ # We need terraform installed for our full test suite so it installs that. # It's updated by running make build-testing-image which will also push a new # image. -FROM circleci/golang:1.16 +FROM circleci/golang:1.17 # Install Terraform ENV TERRAFORM_VERSION=1.0.5 From f2ded06e257955455fc44f869f1c27363e33281f Mon Sep 17 00:00:00 2001 From: Thomas Stig Jacobsen Date: Tue, 31 Aug 2021 05:21:42 +0200 Subject: [PATCH 15/53] deps: bump alpine to 3.14 (#1770) --- docker-base/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-base/Dockerfile b/docker-base/Dockerfile index 8682afcd9a..89313733c4 100644 --- a/docker-base/Dockerfile +++ b/docker-base/Dockerfile @@ -1,7 +1,7 @@ # This Dockerfile builds our base image with gosu, dumb-init and the atlantis # user. We split this from the main Dockerfile because this base doesn't change # and also because it kept breaking the build due to flakiness. -FROM alpine:3.13 +FROM alpine:3.14 LABEL authors="Anubhav Mishra, Luke Kysow" # We use gosu to step down from root and run as the atlantis user so we need From ffda2909c3a0e7d02efc5b3203e91cfedb09e112 Mon Sep 17 00:00:00 2001 From: rui Date: Mon, 30 Aug 2021 23:41:27 -0400 Subject: [PATCH 16/53] workflow: add testing-env image build/publish process (#1780) * workflow: add testing-env image build/publish process replacing https://hub.docker.com/r/runatlantis/testing-env Signed-off-by: Rui Chen * refresh the testing-env image * only runs on master branch Signed-off-by: Rui Chen --- .circleci/config.yml | 2 +- .github/workflows/test.yml | 4 +-- .github/workflows/testing-env-image.yml | 35 +++++++++++++++++++++++++ CONTRIBUTING.md | 4 +-- 4 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/testing-env-image.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index 56d247c290..e3778ecf6a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2 jobs: test: docker: - - image: ghcr.io/runatlantis/testing-env:805e94e7f648eddb0484e539a7b51410d39529bc + - image: ghcr.io/runatlantis/testing-env:2021.08.31 steps: - checkout - run: make test-all diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 963bbabdb1..d87e08ccfe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,10 +4,10 @@ jobs: test: name: runner / gotest runs-on: ubuntu-latest - container: ghcr.io/runatlantis/testing-env:805e94e7f648eddb0484e539a7b51410d39529bc + container: ghcr.io/runatlantis/testing-env:2021.08.31 steps: # user in image needs write access to do anything - name: setup run: sudo chmod -R 777 $GITHUB_WORKSPACE /github /__w/_temp - uses: actions/checkout@v2 - - run: make test-all \ No newline at end of file + - run: make test-all diff --git a/.github/workflows/testing-env-image.yml b/.github/workflows/testing-env-image.yml new file mode 100644 index 0000000000..20e9756c01 --- /dev/null +++ b/.github/workflows/testing-env-image.yml @@ -0,0 +1,35 @@ +name: testing-env-image + +on: + push: + paths: + - ./testing/** + - .github/workflows/testing-env-image.yml + branches: + - "master" + workflow_dispatch: + +defaults: + run: + working-directory: testing + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Login to Packages Container registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - run: echo "TODAY=$(date +"%Y.%m.%d")" >> $GITHUB_ENV + - name: build testing-env:${{env.TODAY}} image + run: | + docker build -t ghcr.io/runatlantis/testing-env:${{env.TODAY}} . + - name: publish testing-env:${{env.TODAY}} image + run: | + docker push ghcr.io/runatlantis/testing-env:${{env.TODAY}} + docker tag ghcr.io/runatlantis/testing-env:${{env.TODAY}} ghcr.io/runatlantis/testing-env:latest + docker push ghcr.io/runatlantis/testing-env:latest diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6dbd795026..d478bb58cb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -68,12 +68,12 @@ docker-compose up --detach --build ## Running Tests In Docker: ``` -docker run --rm -v $(pwd):/go/src/github.com/runatlantis/atlantis -w /go/src/github.com/runatlantis/atlantis runatlantis/testing-env make test +docker run --rm -v $(pwd):/go/src/github.com/runatlantis/atlantis -w /go/src/github.com/runatlantis/atlantis ghcr.io/runatlantis/testing-env:latest make test ``` Or to run the integration tests ``` -docker run --rm -v $(pwd):/go/src/github.com/runatlantis/atlantis -w /go/src/github.com/runatlantis/atlantis runatlantis/testing-env make test-all +docker run --rm -v $(pwd):/go/src/github.com/runatlantis/atlantis -w /go/src/github.com/runatlantis/atlantis ghcr.io/runatlantis/testing-env:latest make test-all ``` ## Calling Your Local Atlantis From GitHub From 8aabf00b672ae086abcb7c2c378d897122ad3d14 Mon Sep 17 00:00:00 2001 From: Nish Krishnan Date: Tue, 31 Aug 2021 15:20:28 -0700 Subject: [PATCH 17/53] 0.17.3 release (#1779) --- CHANGELOG.md | 42 ++++++++++++++++++++++++++++++++++++++++++ kustomize/bundle.yaml | 2 +- main.go | 2 +- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c06c38864c..c6ca34ecfa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,45 @@ +# v0.17.3 +Feature release with a number of improvements related to Gitlab support, a new command, better formatting etc. Some broken features have been fixed in along with some regressions. + +## Features/Improvements +* Add version command to Atlantis for getting the current terraform version ([#1691](https://github.com/runatlantis/atlantis/pull/1691) by @pjsier) +* Support "Pipelines must succeed", "All discussions must be resolved" in Gitlab `apply_requirements` ([#1675](https://github.com/runatlantis/atlantis/pull/1675) by @devlucasc) +* Add support for specifying github app key as a string ([#1706](https://github.com/runatlantis/atlantis/pull/1706) by @dhaven) +* Add flag to enable rich github markdown formatting of terraform outputs ([#1751](https://github.com/runatlantis/atlantis/pull/1751) by @enochlo) + * Note: Depending on feedback here, we will consider just enabling this by default in a future release. +* Add support for splitting large comments into batches for Gitlab ([#1755](https://github.com/runatlantis/atlantis/pull/1755) by @krrrr38) + +## Bug Fixes +* Fix remote ops detection for tf >= 1.0.0 ([#1687](https://github.com/runatlantis/atlantis/pull/1687) by @taavitani) +* Fix Gitlab auto-merge race condition [#1609](https://github.com/runatlantis/atlantis/issues/1609) ([#1675](https://github.com/runatlantis/atlantis/pull/1675) by @devlucasc) +* Fix an issue where `--parallel-pool-size` was being ignored ([#1705](https://github.com/runatlantis/atlantis/pull/1705) by @Schtolc) +* Fix an issue where applies can occur on draft merge requests in Gitlab ([#1736](https://github.com/runatlantis/atlantis/pull/1736) by @devlucasc) +* Fix regression where .terraform.lock.hcl would prevent future operations from upgrading providers even with the `-upgrade` present ([#1701](https://github.com/runatlantis/atlantis/pull/1701) by @gezb) +* Fix issue with branch regex matcher which would always allow all branches ([#1768](https://github.com/runatlantis/atlantis/pull/1768) by @minamijoyo) + +## Dependencies +* Upgrade default tf version to 1.0.5 ([#1662](https://github.com/runatlantis/atlantis/pull/1765) by @chenrui333) +* Upgrade go version to 0.17 ([#1766](https://github.com/runatlantis/atlantis/pull/1766) by @chenrui1333) +* Upgrade alpine to v3.14, addressing CVE-2021-36159, CVE-2021-22924, CVE-2021-22923 and CVE-2021-22925 vulnerabilities ([#1770](https://github.com/runatlantis/atlantis/pull/1770) by @chenrui1333) + +## Backwards Incompatibilities/Notes +* If you are using GHCR and are using the `atlantis:latest` docker image, this now points to the latest release as opposed to the tip of master. If you want to work off the tip of master, then you should now use `atlantis:dev` + +## Downloads +* [atlantis_darwin_amd64.zip](https://github.com/runatlantis/atlantis/releases/download/v0.17.3/atlantis_darwin_amd64.zip) +* [atlantis_linux_386.zip](https://github.com/runatlantis/atlantis/releases/download/v0.17.3/atlantis_linux_386.zip) +* [atlantis_linux_amd64.zip](https://github.com/runatlantis/atlantis/releases/download/v0.17.3/atlantis_linux_amd64.zip) +* [atlantis_linux_arm.zip](https://github.com/runatlantis/atlantis/releases/download/v0.17.3/atlantis_linux_arm.zip) + +## Docker +[`runatlantis/atlantis:v0.17.3`](https://hub.docker.com/r/runatlantis/atlantis/tags/) + +## Github Container Registry +[`ghcr.io/runatlantis/atlantis:v0.17.3`](https://github.com/runatlantis/atlantis/pkgs/container/atlantis) + +## Diff v0.17.2..v0.17.3 +https://github.com/runatlantis/atlantis/compare/v0.17.2...v0.17.3 + # v0.17.2 Patch release containing bug fixes. diff --git a/kustomize/bundle.yaml b/kustomize/bundle.yaml index 0f0ad75ffc..8132f07cb4 100644 --- a/kustomize/bundle.yaml +++ b/kustomize/bundle.yaml @@ -22,7 +22,7 @@ spec: fsGroup: 1000 # Atlantis group (1000) read/write access to volumes. containers: - name: atlantis - image: runatlantis/atlantis:v0.17.2 + image: runatlantis/atlantis:v0.17.3 env: - name: ATLANTIS_DATA_DIR value: /atlantis diff --git a/main.go b/main.go index 169cb6f153..bbde2aa491 100644 --- a/main.go +++ b/main.go @@ -22,7 +22,7 @@ import ( "github.com/spf13/viper" ) -const atlantisVersion = "0.17.2" +const atlantisVersion = "0.17.3" func main() { v := viper.New() From 00d2abe25c2a02ed6f12f4c92e99cc503134ef7e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 Sep 2021 00:24:50 -0400 Subject: [PATCH 18/53] build(deps): bump tar from 4.4.15 to 4.4.19 (#1783) Bumps [tar](https://github.com/npm/node-tar) from 4.4.15 to 4.4.19. - [Release notes](https://github.com/npm/node-tar/releases) - [Changelog](https://github.com/npm/node-tar/blob/main/CHANGELOG.md) - [Commits](https://github.com/npm/node-tar/compare/v4.4.15...v4.4.19) --- updated-dependencies: - dependency-name: tar dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/yarn.lock b/yarn.lock index 1057da8f87..f32f477d28 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1442,7 +1442,7 @@ chokidar@^2.0.2, chokidar@^2.0.3: optionalDependencies: fsevents "^1.2.2" -chownr@^1.0.1, chownr@^1.1.1: +chownr@^1.0.1, chownr@^1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.4.tgz#6fc9d7b42d32a583596337666e7d08084da2cc6b" @@ -2466,7 +2466,7 @@ fs-extra@^5.0.0: jsonfile "^4.0.0" universalify "^0.1.0" -fs-minipass@^1.2.5: +fs-minipass@^1.2.7: version "1.2.7" resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.7.tgz#ccff8570841e7fe4265693da88936c55aed7f7c7" dependencies: @@ -3715,14 +3715,14 @@ minimist@^1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" -minipass@^2.6.0, minipass@^2.8.6, minipass@^2.9.0: +minipass@^2.6.0, minipass@^2.9.0: version "2.9.0" resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.9.0.tgz#e713762e7d3e32fed803115cf93e04bca9fcc9a6" dependencies: safe-buffer "^5.1.2" yallist "^3.0.0" -minizlib@^1.2.1: +minizlib@^1.3.3: version "1.3.3" resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.3.3.tgz#2290de96818a34c29551c8a8d301216bd65a861d" dependencies: @@ -3754,7 +3754,7 @@ mkdirp@0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.3.0.tgz#1bbf5ab1ba827af23575143490426455f481fe1e" -mkdirp@0.5.x, mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@~0.5.1: +mkdirp@0.5.x, mkdirp@^0.5.1, mkdirp@^0.5.5, mkdirp@~0.5.0, mkdirp@~0.5.1: version "0.5.5" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" dependencies: @@ -4941,7 +4941,7 @@ run-queue@^1.0.0, run-queue@^1.0.3: dependencies: aproba "^1.1.1" -safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2: +safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.1: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" @@ -5340,16 +5340,16 @@ tapable@^1.0.0: resolved "https://registry.yarnpkg.com/tapable/-/tapable-1.0.0.tgz#cbb639d9002eed9c6b5975eb20598d7936f1f9f2" tar@^4: - version "4.4.15" - resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.15.tgz#3caced4f39ebd46ddda4d6203d48493a919697f8" - dependencies: - chownr "^1.1.1" - fs-minipass "^1.2.5" - minipass "^2.8.6" - minizlib "^1.2.1" - mkdirp "^0.5.0" - safe-buffer "^5.1.2" - yallist "^3.0.3" + version "4.4.19" + resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.19.tgz#2e4d7263df26f2b914dee10c825ab132123742f3" + dependencies: + chownr "^1.1.4" + fs-minipass "^1.2.7" + minipass "^2.9.0" + minizlib "^1.3.3" + mkdirp "^0.5.5" + safe-buffer "^5.2.1" + yallist "^3.1.1" term-size@^1.2.0: version "1.2.0" @@ -6136,7 +6136,7 @@ yallist@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" -yallist@^3.0.0, yallist@^3.0.3: +yallist@^3.0.0, yallist@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" From 55c5ce89bb19f4561909641137158d093f22a772 Mon Sep 17 00:00:00 2001 From: Rui Chen Date: Thu, 2 Sep 2021 00:33:32 -0400 Subject: [PATCH 19/53] docs: move badges up and remove gitter support Signed-off-by: Rui Chen --- README.md | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f89faaf276..e3533e8f7a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,11 @@ # Atlantis +[![SuperDopeBadge](./runatlantis.io/.vuepress/public/hightower-super-dope.svg)](https://twitter.com/kelseyhightower/status/893260922222813184) +[![Go Report Card](https://goreportcard.com/badge/github.com/runatlantis/atlantis)](https://goreportcard.com/report/github.com/runatlantis/atlantis) +[![codecov](https://codecov.io/gh/runatlantis/atlantis/branch/master/graph/badge.svg)](https://codecov.io/gh/runatlantis/atlantis) +[![CircleCI](https://circleci.com/gh/runatlantis/atlantis/tree/master.svg?style=shield)](https://circleci.com/gh/runatlantis/atlantis/tree/master) +[![Slack](https://img.shields.io/badge/Join-Atlantis%20Community%20Slack-red)](https://join.slack.com/t/atlantis-community/shared_invite/enQtNzc4NDM3OTA3ODI0LTA5NDQ4YTA3NTAxM2I3ZmIxMGNiYWJhNmY4YjBjZjM3OWMzNGI0NTcxNzY2NjRhODIyODA4YmNjOTBiOThhNTI) +

    Atlantis Logo

    Terraform Pull Request Automation @@ -9,7 +15,6 @@ - [What is Atlantis?](#what-is-atlantis) - [What does it do?](#what-does-it-do) - [Why should you use it?](#why-should-you-use-it) -- [Badges!](#badges) - [Stargazers over time](#stargazers-over-time) ## Resources @@ -30,14 +35,6 @@ Runs `terraform plan` and `apply` remotely and comments back on the pull request * Enable non-operations engineers to collaborate on Terraform. * Standardize your Terraform workflows. -## Badges! -[![SuperDopeBadge](./runatlantis.io/.vuepress/public/hightower-super-dope.svg)](https://twitter.com/kelseyhightower/status/893260922222813184) -[![Go Report Card](https://goreportcard.com/badge/github.com/runatlantis/atlantis)](https://goreportcard.com/report/github.com/runatlantis/atlantis) -[![codecov](https://codecov.io/gh/runatlantis/atlantis/branch/master/graph/badge.svg)](https://codecov.io/gh/runatlantis/atlantis) -[![CircleCI](https://circleci.com/gh/runatlantis/atlantis/tree/master.svg?style=shield)](https://circleci.com/gh/runatlantis/atlantis/tree/master) -[![Slack](https://img.shields.io/badge/Join-Atlantis%20Community%20Slack-red)](https://join.slack.com/t/atlantis-community/shared_invite/enQtNzc4NDM3OTA3ODI0LTA5NDQ4YTA3NTAxM2I3ZmIxMGNiYWJhNmY4YjBjZjM3OWMzNGI0NTcxNzY2NjRhODIyODA4YmNjOTBiOThhNTI) -[![Gitter chat](https://badges.gitter.im/runatlantis.png)](https://gitter.im/runatlantis) - ## Stargazers over time [![Stargazers over time](https://starchart.cc/runatlantis/atlantis.svg)](https://starchart.cc/runatlantis/atlantis) From 7f884fa052e5d0e3c75090e6426ed49c8e2aadfb Mon Sep 17 00:00:00 2001 From: Rui Chen Date: Thu, 2 Sep 2021 00:35:52 -0400 Subject: [PATCH 20/53] docs: remove gitter support Signed-off-by: Rui Chen --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e3533e8f7a..e653e4d112 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ * How to get started: [www.runatlantis.io/guide](https://www.runatlantis.io/guide) * Full documentation: [www.runatlantis.io/docs](https://www.runatlantis.io/docs) * Download the latest release: [github.com/runatlantis/atlantis/releases/latest](https://github.com/runatlantis/atlantis/releases/latest) -* Get help in our [Slack channel](https://thawing-headland-22460.herokuapp.com) or our [Gitter channel](https://gitter.im/runatlantis/Lobby) +* Get help in our [Slack channel](https://thawing-headland-22460.herokuapp.com) * Start Contributing: [CONTRIBUTING.md](CONTRIBUTING.md) ## What is Atlantis? From db1cb4a649a08cad13086f44d049be32994f4893 Mon Sep 17 00:00:00 2001 From: rui Date: Fri, 3 Sep 2021 11:41:18 -0400 Subject: [PATCH 21/53] build: tf 1.0.6 (#1786) Signed-off-by: Rui Chen --- .circleci/config.yml | 2 +- Dockerfile | 2 +- testing/Dockerfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e3778ecf6a..9dd997cdf0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,7 +16,7 @@ jobs: # We do this instead of setting --default-tf-version because setting # that flag starts the download asynchronously so we'd have a race # condition. - TERRAFORM_VERSION: 1.0.5 + TERRAFORM_VERSION: 1.0.6 steps: - checkout - run: make build-service diff --git a/Dockerfile b/Dockerfile index 35fe3cf006..0d161ed2a1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM ghcr.io/runatlantis/atlantis-base:2021.06.22 # install terraform binaries -ENV DEFAULT_TERRAFORM_VERSION=1.0.5 +ENV DEFAULT_TERRAFORM_VERSION=1.0.6 # In the official Atlantis image we only have the latest of each Terraform version. RUN AVAILABLE_TERRAFORM_VERSIONS="0.8.8 0.9.11 0.10.8 0.11.15 0.12.31 0.13.7 0.14.11 0.15.5 ${DEFAULT_TERRAFORM_VERSION}" && \ diff --git a/testing/Dockerfile b/testing/Dockerfile index aacf341032..2dfdd21d30 100644 --- a/testing/Dockerfile +++ b/testing/Dockerfile @@ -5,7 +5,7 @@ FROM circleci/golang:1.17 # Install Terraform -ENV TERRAFORM_VERSION=1.0.5 +ENV TERRAFORM_VERSION=1.0.6 RUN curl -LOks https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip && \ sudo mkdir -p /usr/local/bin/tf/versions/${TERRAFORM_VERSION} && \ sudo unzip terraform_${TERRAFORM_VERSION}_linux_amd64.zip -d /usr/local/bin/tf/versions/${TERRAFORM_VERSION} && \ From f5e0eed619fbebb719172f39341352afbf57903d Mon Sep 17 00:00:00 2001 From: Rui Chen Date: Fri, 3 Sep 2021 15:34:35 -0400 Subject: [PATCH 22/53] e2e: cleanup go.mod Signed-off-by: Rui Chen --- e2e/go.mod | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/e2e/go.mod b/e2e/go.mod index fd0c4355a4..6df8833bd0 100644 --- a/e2e/go.mod +++ b/e2e/go.mod @@ -4,11 +4,8 @@ go 1.17 require ( github.com/google/go-github/v28 v28.0.0 - github.com/hashicorp/go-multierror v1.0.0 -) - -require ( github.com/google/go-querystring v1.0.0 // indirect github.com/hashicorp/errwrap v1.0.0 // indirect + github.com/hashicorp/go-multierror v1.0.0 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 // indirect ) From ce92a6aa31ace6854384d586b85fb31a1b836325 Mon Sep 17 00:00:00 2001 From: Nish Krishnan Date: Fri, 3 Sep 2021 14:04:31 -0700 Subject: [PATCH 23/53] Bump testing image conftest version to 0.27 (#1787) --- Dockerfile.dev | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.dev b/Dockerfile.dev index fb19d0ba40..3d8ecf7db1 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,6 +1,6 @@ FROM runatlantis/atlantis:latest COPY atlantis /usr/local/bin/atlantis # TODO: remove this once we get this in the base image -ENV DEFAULT_CONFTEST_VERSION=0.25.0 +ENV DEFAULT_CONFTEST_VERSION=0.27.0 WORKDIR /atlantis/src From 34426b6b2f88b3d0ba649d37581b646d424e526a Mon Sep 17 00:00:00 2001 From: Nish Krishnan Date: Fri, 3 Sep 2021 14:14:16 -0700 Subject: [PATCH 24/53] Actually bump testing image conftest version to 0.27 (#1788) --- testing/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/Dockerfile b/testing/Dockerfile index 2dfdd21d30..a5cbc7b7e8 100644 --- a/testing/Dockerfile +++ b/testing/Dockerfile @@ -13,7 +13,7 @@ RUN curl -LOks https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/ter rm terraform_${TERRAFORM_VERSION}_linux_amd64.zip # Install conftest -ENV DEFAULT_CONFTEST_VERSION=0.25.0 +ENV DEFAULT_CONFTEST_VERSION=0.27.0 RUN AVAILABLE_CONFTEST_VERSIONS="${DEFAULT_CONFTEST_VERSION}" && \ for VERSION in ${AVAILABLE_CONFTEST_VERSIONS}; do \ From fae93aecb6a43011d74538b2d559450729b47acd Mon Sep 17 00:00:00 2001 From: rui Date: Fri, 3 Sep 2021 18:13:44 -0400 Subject: [PATCH 25/53] build: fix testing-env img process (#1789) * remove circleci img comment Signed-off-by: Rui Chen * test img build Signed-off-by: Rui Chen * Revert "test img build" This reverts commit fae6ee43a5f7a865774492bdc2c3d634726e3305. --- testing/Dockerfile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/testing/Dockerfile b/testing/Dockerfile index a5cbc7b7e8..227d38307e 100644 --- a/testing/Dockerfile +++ b/testing/Dockerfile @@ -1,7 +1,3 @@ -# This Dockerfile builds the docker image used for running circle ci tests. -# We need terraform installed for our full test suite so it installs that. -# It's updated by running make build-testing-image which will also push a new -# image. FROM circleci/golang:1.17 # Install Terraform From e021dbf8d484a57bdac67c147677150736e5ff4a Mon Sep 17 00:00:00 2001 From: Rui Chen Date: Fri, 3 Sep 2021 18:30:58 -0400 Subject: [PATCH 26/53] workflow(testing-env-image): update path trigger Signed-off-by: Rui Chen --- .github/workflows/testing-env-image.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/testing-env-image.yml b/.github/workflows/testing-env-image.yml index 20e9756c01..41502d5352 100644 --- a/.github/workflows/testing-env-image.yml +++ b/.github/workflows/testing-env-image.yml @@ -3,10 +3,10 @@ name: testing-env-image on: push: paths: - - ./testing/** - - .github/workflows/testing-env-image.yml + - 'testing/**' + - '.github/workflows/testing-env-image.yml' branches: - - "master" + - 'master' workflow_dispatch: defaults: From 72491335e4806a97c6d19de9fab8136da20b87f5 Mon Sep 17 00:00:00 2001 From: rui Date: Sat, 4 Sep 2021 15:18:22 -0400 Subject: [PATCH 27/53] e2e: update dockerfile (#1790) * e2e: update dockerfile Signed-off-by: Rui Chen * test workflow Signed-off-by: Rui Chen * trigger a docker build Signed-off-by: Rui Chen * revert Signed-off-by: Rui Chen * Update Dockerfile * update dockerfile Signed-off-by: Rui Chen * Update Dockerfile * Update testing-env-image.yml --- testing/Dockerfile | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/testing/Dockerfile b/testing/Dockerfile index 227d38307e..dad46be829 100644 --- a/testing/Dockerfile +++ b/testing/Dockerfile @@ -9,17 +9,14 @@ RUN curl -LOks https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/ter rm terraform_${TERRAFORM_VERSION}_linux_amd64.zip # Install conftest -ENV DEFAULT_CONFTEST_VERSION=0.27.0 +ENV CONFTEST_VERSION=0.27.0 +RUN curl -LOs https://github.com/open-policy-agent/conftest/releases/download/v${CONFTEST_VERSION}/conftest_${CONFTEST_VERSION}_Linux_x86_64.tar.gz && \ + curl -LOs https://github.com/open-policy-agent/conftest/releases/download/v${CONFTEST_VERSION}/checksums.txt && \ + sed -n "/conftest_${CONFTEST_VERSION}_Linux_x86_64.tar.gz/p" checksums.txt | sha256sum -c && \ + sudo mkdir -p /usr/local/bin/cft/versions/${CONFTEST_VERSION} && \ + sudo tar -C /usr/local/bin/cft/versions/${CONFTEST_VERSION} -xzf conftest_${CONFTEST_VERSION}_Linux_x86_64.tar.gz && \ + sudo ln -s /usr/local/bin/cft/versions/${CONFTEST_VERSION}/conftest /usr/local/bin/conftest${CONFTEST_VERSION} && \ + rm conftest_${CONFTEST_VERSION}_Linux_x86_64.tar.gz && \ + rm checksums.txt -RUN AVAILABLE_CONFTEST_VERSIONS="${DEFAULT_CONFTEST_VERSION}" && \ - for VERSION in ${AVAILABLE_CONFTEST_VERSIONS}; do \ - curl -LOs https://github.com/open-policy-agent/conftest/releases/download/v${VERSION}/conftest_${VERSION}_Linux_x86_64.tar.gz && \ - curl -LOs https://github.com/open-policy-agent/conftest/releases/download/v${VERSION}/checksums.txt && \ - sed -n "/conftest_${VERSION}_Linux_x86_64.tar.gz/p" checksums.txt | sha256sum -c && \ - sudo mkdir -p /usr/local/bin/cft/versions/${VERSION} && \ - sudo tar -C /usr/local/bin/cft/versions/${VERSION} -xzf conftest_${VERSION}_Linux_x86_64.tar.gz && \ - sudo ln -s /usr/local/bin/cft/versions/${VERSION}/conftest /usr/local/bin/conftest${VERSION} && \ - rm conftest_${VERSION}_Linux_x86_64.tar.gz && \ - rm checksums.txt; \ - done RUN go get golang.org/x/tools/cmd/goimports From 5917c47349514f5a8f7113e4fcd40845b4e71e13 Mon Sep 17 00:00:00 2001 From: Rui Chen Date: Sat, 4 Sep 2021 15:44:05 -0400 Subject: [PATCH 28/53] docker: use ghcr.io images rather than docker hub ones Signed-off-by: Rui Chen --- Dockerfile.dev | 2 +- kustomize/bundle.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.dev b/Dockerfile.dev index 3d8ecf7db1..7726bb08d0 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,4 +1,4 @@ -FROM runatlantis/atlantis:latest +FROM ghcr.io/runatlantis/atlantis:latest COPY atlantis /usr/local/bin/atlantis # TODO: remove this once we get this in the base image ENV DEFAULT_CONFTEST_VERSION=0.27.0 diff --git a/kustomize/bundle.yaml b/kustomize/bundle.yaml index 8132f07cb4..3c2f4e56e3 100644 --- a/kustomize/bundle.yaml +++ b/kustomize/bundle.yaml @@ -22,7 +22,7 @@ spec: fsGroup: 1000 # Atlantis group (1000) read/write access to volumes. containers: - name: atlantis - image: runatlantis/atlantis:v0.17.3 + image: ghcr.io/runatlantis/atlantis:v0.17.3 env: - name: ATLANTIS_DATA_DIR value: /atlantis From b4cb071907f417dfd1e71d7a5d64e903151d69d0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 8 Sep 2021 15:03:52 -0400 Subject: [PATCH 29/53] build(deps): bump runatlantis/atlantis-base (#1794) Bumps runatlantis/atlantis-base from 2021.06.22 to 2021.08.31. --- updated-dependencies: - dependency-name: runatlantis/atlantis-base dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0d161ed2a1..5af6c55b6b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # The runatlantis/atlantis-base is created by docker-base/Dockerfile. -FROM ghcr.io/runatlantis/atlantis-base:2021.06.22 +FROM ghcr.io/runatlantis/atlantis-base:2021.08.31 # install terraform binaries ENV DEFAULT_TERRAFORM_VERSION=1.0.6 From 63f252a9902f76020f66d1a737f8fc0a7e39873c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 8 Sep 2021 15:04:21 -0400 Subject: [PATCH 30/53] build(deps): bump github.com/xanzy/go-gitlab from 0.50.3 to 0.50.4 (#1795) Bumps [github.com/xanzy/go-gitlab](https://github.com/xanzy/go-gitlab) from 0.50.3 to 0.50.4. - [Release notes](https://github.com/xanzy/go-gitlab/releases) - [Changelog](https://github.com/xanzy/go-gitlab/blob/master/releases_test.go) - [Commits](https://github.com/xanzy/go-gitlab/compare/v0.50.3...v0.50.4) --- updated-dependencies: - dependency-name: github.com/xanzy/go-gitlab dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 3b72ef27c3..6051e1340a 100644 --- a/go.mod +++ b/go.mod @@ -95,7 +95,7 @@ require ( github.com/ulikunitz/xz v0.5.8 // indirect github.com/urfave/cli v1.22.5 github.com/urfave/negroni v0.3.0 - github.com/xanzy/go-gitlab v0.50.3 + github.com/xanzy/go-gitlab v0.50.4 github.com/zclconf/go-cty v1.5.1 // indirect go.etcd.io/bbolt v1.3.6 go.opencensus.io v0.23.0 // indirect diff --git a/go.sum b/go.sum index 996b50bba4..b757703e94 100644 --- a/go.sum +++ b/go.sum @@ -405,8 +405,8 @@ github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtX github.com/urfave/negroni v0.3.0 h1:PaXOb61mWeZJxc1Ji2xJjpVg9QfPo0rrB+lHyBxGNSU= github.com/urfave/negroni v0.3.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= -github.com/xanzy/go-gitlab v0.50.3 h1:M7ncgNhCN4jaFNyXxarJhCLa9Qi6fdmCxFFhMTQPZiY= -github.com/xanzy/go-gitlab v0.50.3/go.mod h1:Q+hQhV508bDPoBijv7YjK/Lvlb4PhVhJdKqXVQrUoAE= +github.com/xanzy/go-gitlab v0.50.4 h1:DA0+D9eTBnZvrGBOQ66XV4ZV9gOFXKbbgm9L99EKCUs= +github.com/xanzy/go-gitlab v0.50.4/go.mod h1:Q+hQhV508bDPoBijv7YjK/Lvlb4PhVhJdKqXVQrUoAE= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= From 4aa49217b5df73fb13fce79276b197bc74aca219 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 8 Sep 2021 20:05:51 +0100 Subject: [PATCH 31/53] fix a typo (#1796) --- server/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/server.go b/server/server.go index 5c8324839b..dbf3992921 100644 --- a/server/server.go +++ b/server/server.go @@ -808,7 +808,7 @@ func (s *Server) Index(w http.ResponseWriter, _ *http.Request) { func mkSubDir(parentDir string, subDir string) (string, error) { fullDir := filepath.Join(parentDir, subDir) if err := os.MkdirAll(fullDir, 0700); err != nil { - return "", errors.Wrapf(err, "unable to creare dir %q", fullDir) + return "", errors.Wrapf(err, "unable to create dir %q", fullDir) } return fullDir, nil From a2d82b9f45446e5182144e4c89ab745018b1934e Mon Sep 17 00:00:00 2001 From: Sarvar Muminov <43311+msarvar@users.noreply.github.com> Date: Thu, 9 Sep 2021 09:21:26 -0700 Subject: [PATCH 32/53] Set ParallelPolicyCheckEnabled to the same value as ParallelPlanEnabled (#1802) --- .../events/project_command_context_builder.go | 51 ++++++++++--------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/server/events/project_command_context_builder.go b/server/events/project_command_context_builder.go index da5a0810f3..1f2cd3e119 100644 --- a/server/events/project_command_context_builder.go +++ b/server/events/project_command_context_builder.go @@ -186,31 +186,32 @@ func newProjectCommandContext(ctx *CommandContext, } return models.ProjectCommandContext{ - CommandName: cmd, - ApplyCmd: applyCmd, - BaseRepo: ctx.Pull.BaseRepo, - EscapedCommentArgs: escapedCommentArgs, - AutomergeEnabled: automergeEnabled, - DeleteSourceBranchOnMerge: deleteSourceBranchOnMerge, - ParallelApplyEnabled: parallelApplyEnabled, - ParallelPlanEnabled: parallelPlanEnabled, - AutoplanEnabled: projCfg.AutoplanEnabled, - Steps: steps, - HeadRepo: ctx.HeadRepo, - Log: ctx.Log, - PullMergeable: ctx.PullMergeable, - ProjectPlanStatus: projectPlanStatus, - Pull: ctx.Pull, - ProjectName: projCfg.Name, - ApplyRequirements: projCfg.ApplyRequirements, - RePlanCmd: planCmd, - RepoRelDir: projCfg.RepoRelDir, - RepoConfigVersion: projCfg.RepoCfgVersion, - TerraformVersion: projCfg.TerraformVersion, - User: ctx.User, - Verbose: verbose, - Workspace: projCfg.Workspace, - PolicySets: policySets, + CommandName: cmd, + ApplyCmd: applyCmd, + BaseRepo: ctx.Pull.BaseRepo, + EscapedCommentArgs: escapedCommentArgs, + AutomergeEnabled: automergeEnabled, + DeleteSourceBranchOnMerge: deleteSourceBranchOnMerge, + ParallelApplyEnabled: parallelApplyEnabled, + ParallelPlanEnabled: parallelPlanEnabled, + ParallelPolicyCheckEnabled: parallelPlanEnabled, + AutoplanEnabled: projCfg.AutoplanEnabled, + Steps: steps, + HeadRepo: ctx.HeadRepo, + Log: ctx.Log, + PullMergeable: ctx.PullMergeable, + ProjectPlanStatus: projectPlanStatus, + Pull: ctx.Pull, + ProjectName: projCfg.Name, + ApplyRequirements: projCfg.ApplyRequirements, + RePlanCmd: planCmd, + RepoRelDir: projCfg.RepoRelDir, + RepoConfigVersion: projCfg.RepoCfgVersion, + TerraformVersion: projCfg.TerraformVersion, + User: ctx.User, + Verbose: verbose, + Workspace: projCfg.Workspace, + PolicySets: policySets, } } From c3050285e4d1888f043c3392af2e5e5a10c8dfd8 Mon Sep 17 00:00:00 2001 From: Frank Bagherzadeh Date: Thu, 9 Sep 2021 14:37:15 -0400 Subject: [PATCH 33/53] docs: Add missing --silence-vcs-status-no-plans flag (#1803) `The Silence VCS Status` feature has been implemented in #954. However there is no reference to it in the server side repo config. Add missing `The Silence VCS Status` `--silence-vcs-status-no-plans` in the reference for server side repo config. --- runatlantis.io/docs/server-configuration.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/runatlantis.io/docs/server-configuration.md b/runatlantis.io/docs/server-configuration.md index 34487bc534..0035ddbd70 100644 --- a/runatlantis.io/docs/server-configuration.md +++ b/runatlantis.io/docs/server-configuration.md @@ -560,6 +560,12 @@ Values are chosen in this order: This is useful when running multiple Atlantis servers against a single repository so you can delegate work to each Atlantis server. Also useful when used with pre_workflow_hooks to dynamically generate an `atlantis.yaml` file. +* ### `--silence-vcs-status-no-plans` + ```bash + atlantis server --silence-vcs-status-no-plans + ``` + `--silence-vcs-status-no-plans` will tell Atlantis to ignore setting VCS status if none of the modified files are part of a project defined in the `atlantis.yaml` file. + * ### `--skip-clone-no-changes` ```bash atlantis server --skip-clone-no-changes From 4b6c2f65daf605f02738ad9c180b235f8ff6c7af Mon Sep 17 00:00:00 2001 From: Masayuki Morita Date: Sat, 11 Sep 2021 01:14:56 +0900 Subject: [PATCH 34/53] build(lint): use revive instead of golint (#1801) * Use revive instead of golint The golint was officially deprecated. https://github.com/golang/go/issues/38968 We have been using golint via golangci-lint and golangci-lint now recommends using revive instead of golint. https://golangci-lint.run/usage/linters/ > golint: The repository of the linter has been archived by the owner. > Replaced by revive. The revive is a drop-in replacement of golint. I think switching to revive is a reasonable choice to check the same rules for free. https://github.com/mgechev/revive * Fix lint errors reported by revive The revive is almost the same as golint, but there seems to be a bit different results. https://app.circleci.com/pipelines/github/runatlantis/atlantis/1519/workflows/75fd7da5-1532-4ed7-ac8a-4884902818a4/jobs/8314 https://github.com/runatlantis/atlantis/runs/3565887247?check_suite_focus=true --- .github/workflows/lint.yml | 12 ++++++------ .golangci.yml | 2 +- server/core/locking/locking_test.go | 2 +- server/core/runtime/policy/conftest_client.go | 4 ++-- .../events/pre_workflow_hooks_command_runner_test.go | 6 +++--- server/events/yaml/valid/global_cfg.go | 2 +- testdrive/utils.go | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2cf420a1ef..29a5aab838 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,18 +14,18 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} tool_name: golangci-lint - # Use golint via golangci-lint binary with "warning" level. - golint: - name: runner / golint + # Use revive via golangci-lint binary with "warning" level. + revive: + name: runner / revive runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory uses: actions/checkout@v1 - - name: golint + - name: revive uses: reviewdog/action-golangci-lint@v2 with: - golangci_lint_flags: "--disable-all -E golint" - tool_name: golint # Change reporter name. + golangci_lint_flags: "--disable-all -E revive" + tool_name: revive # Change reporter name. level: warning # GitHub Status Check won't become failure with this level. # You can add more and more supported linters with different config. diff --git a/.golangci.yml b/.golangci.yml index 0630766f93..e403447ec5 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -6,7 +6,7 @@ linters: # We don't use goconst because it gives false positives in the tests. # - goconst - gofmt - - golint + - revive - gosec - gosimple - ineffassign diff --git a/server/core/locking/locking_test.go b/server/core/locking/locking_test.go index fd8ce1e328..316b770ba5 100644 --- a/server/core/locking/locking_test.go +++ b/server/core/locking/locking_test.go @@ -178,7 +178,7 @@ func TestGetLock_NoOpLocker(t *testing.T) { l := locking.NewNoOpLocker() lock, err := l.GetLock("owner/repo/path/workspace") Ok(t, err) - var expected *models.ProjectLock = nil + var expected *models.ProjectLock Equals(t, expected, lock) } diff --git a/server/core/runtime/policy/conftest_client.go b/server/core/runtime/policy/conftest_client.go index 8adfdc99c4..620361f3c7 100644 --- a/server/core/runtime/policy/conftest_client.go +++ b/server/core/runtime/policy/conftest_client.go @@ -94,7 +94,7 @@ func (p *SourceResolverProxy) Resolve(policySet valid.PolicySet) (string, error) case valid.LocalPolicySet: return p.localSourceResolver.Resolve(policySet) default: - return "", errors.New(fmt.Sprintf("unable to resolve policy set source %s", source)) + return "", fmt.Errorf("unable to resolve policy set source %s", source) } } @@ -237,7 +237,7 @@ func getDefaultVersion() (*version.Version, error) { defaultVersion, exists := os.LookupEnv(DefaultConftestVersionEnvKey) if !exists { - return nil, errors.New(fmt.Sprintf("%s not set.", DefaultConftestVersionEnvKey)) + return nil, fmt.Errorf("%s not set", DefaultConftestVersionEnvKey) } wrappedVersion, err := version.NewVersion(defaultVersion) diff --git a/server/events/pre_workflow_hooks_command_runner_test.go b/server/events/pre_workflow_hooks_command_runner_test.go index e384a52353..3476e8446b 100644 --- a/server/events/pre_workflow_hooks_command_runner_test.go +++ b/server/events/pre_workflow_hooks_command_runner_test.go @@ -74,7 +74,7 @@ func TestRunPreHooks_Clone(t *testing.T) { t.Run("success hooks in cfg", func(t *testing.T) { preWorkflowHooksSetup(t) - var unlockCalled *bool = newBool(false) + var unlockCalled = newBool(false) unlockFn := func() { unlockCalled = newBool(true) } @@ -159,7 +159,7 @@ func TestRunPreHooks_Clone(t *testing.T) { t.Run("error cloning", func(t *testing.T) { preWorkflowHooksSetup(t) - var unlockCalled *bool = newBool(false) + var unlockCalled = newBool(false) unlockFn := func() { unlockCalled = newBool(true) } @@ -191,7 +191,7 @@ func TestRunPreHooks_Clone(t *testing.T) { t.Run("error running pre hook", func(t *testing.T) { preWorkflowHooksSetup(t) - var unlockCalled *bool = newBool(false) + var unlockCalled = newBool(false) unlockFn := func() { unlockCalled = newBool(true) } diff --git a/server/events/yaml/valid/global_cfg.go b/server/events/yaml/valid/global_cfg.go index 81068d11ab..6a630a8ca8 100644 --- a/server/events/yaml/valid/global_cfg.go +++ b/server/events/yaml/valid/global_cfg.go @@ -27,7 +27,7 @@ const DeleteSourceBranchOnMergeKey = "delete_source_branch_on_merge" // TODO: Make this more customizable, not everyone wants this rigid workflow // maybe something along the lines of defining overridable/non-overrideable apply // requirements in the config and removing the flag to enable policy checking. -var NonOverrideableApplyReqs []string = []string{PoliciesPassedApplyReq} +var NonOverrideableApplyReqs = []string{PoliciesPassedApplyReq} // GlobalCfg is the final parsed version of server-side repo config. type GlobalCfg struct { diff --git a/testdrive/utils.go b/testdrive/utils.go index 77645e45b6..1452951a20 100644 --- a/testdrive/utils.go +++ b/testdrive/utils.go @@ -214,7 +214,7 @@ func execAndWaitForStderr(wg *sync.WaitGroup, stderrMatch *regexp.Regexp, timeou cancel() // We still need to wait for the command to finish. command.Wait() // nolint: errcheck - return cancel, errChan, fmt.Errorf("timeout, logs:\n%s\n", log) // nolint: staticcheck, golint + return cancel, errChan, fmt.Errorf("timeout, logs:\n%s\n", log) // nolint: staticcheck, revive } // Increment the wait group so callers can wait for the command to finish. From 4ad308538e5a0801345c7ea9715b2330e744ad72 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Sep 2021 10:14:03 -0400 Subject: [PATCH 35/53] build(deps): bump github.com/hashicorp/go-getter from 1.5.7 to 1.5.8 (#1807) Bumps [github.com/hashicorp/go-getter](https://github.com/hashicorp/go-getter) from 1.5.7 to 1.5.8. - [Release notes](https://github.com/hashicorp/go-getter/releases) - [Changelog](https://github.com/hashicorp/go-getter/blob/main/.goreleaser.yml) - [Commits](https://github.com/hashicorp/go-getter/compare/v1.5.7...v1.5.8) --- updated-dependencies: - dependency-name: github.com/hashicorp/go-getter dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6051e1340a..e09f09385c 100644 --- a/go.mod +++ b/go.mod @@ -42,7 +42,7 @@ require ( github.com/gorilla/mux v1.8.0 github.com/gorilla/websocket v1.4.2 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-getter v1.5.7 + github.com/hashicorp/go-getter v1.5.8 github.com/hashicorp/go-retryablehttp v0.6.8 // indirect github.com/hashicorp/go-safetemp v1.0.0 // indirect github.com/hashicorp/go-version v1.3.0 diff --git a/go.sum b/go.sum index b757703e94..b7dcaa3d93 100644 --- a/go.sum +++ b/go.sum @@ -216,8 +216,8 @@ github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-getter v1.5.7 h1:HBLsom8eGHLxj78ta+/MVSyct8KWG4B4z6lhBA4vJcg= -github.com/hashicorp/go-getter v1.5.7/go.mod h1:BrrV/1clo8cCYu6mxvboYg+KutTiFnXjMEgDD8+i7ZI= +github.com/hashicorp/go-getter v1.5.8 h1:qx5CZXxXz5YFpALPkbf/F1iZZoRE+f6T1i/AWw/Zkic= +github.com/hashicorp/go-getter v1.5.8/go.mod h1:BrrV/1clo8cCYu6mxvboYg+KutTiFnXjMEgDD8+i7ZI= github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxCsHI= github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= From ff00a7e316a0e6440b72b54471de5846875843e7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Sep 2021 10:14:10 -0400 Subject: [PATCH 36/53] build(deps): bump go.uber.org/zap from 1.19.0 to 1.19.1 (#1808) Bumps [go.uber.org/zap](https://github.com/uber-go/zap) from 1.19.0 to 1.19.1. - [Release notes](https://github.com/uber-go/zap/releases) - [Changelog](https://github.com/uber-go/zap/blob/master/CHANGELOG.md) - [Commits](https://github.com/uber-go/zap/compare/v1.19.0...v1.19.1) --- updated-dependencies: - dependency-name: go.uber.org/zap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index e09f09385c..581857c234 100644 --- a/go.mod +++ b/go.mod @@ -101,7 +101,7 @@ require ( go.opencensus.io v0.23.0 // indirect go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect - go.uber.org/zap v1.19.0 + go.uber.org/zap v1.19.1 golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect golang.org/x/mod v0.4.2 // indirect @@ -110,7 +110,7 @@ require ( golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect golang.org/x/text v0.3.6 // indirect golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect - golang.org/x/tools v0.1.2 // indirect + golang.org/x/tools v0.1.5 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect google.golang.org/api v0.44.0 // indirect google.golang.org/appengine v1.6.7 // indirect diff --git a/go.sum b/go.sum index b7dcaa3d93..a6b8ffb9e7 100644 --- a/go.sum +++ b/go.sum @@ -431,13 +431,13 @@ go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= -go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/goleak v1.1.11-0.20210813005559-691160354723 h1:sHOAIxRGBp443oHZIPB+HsUGaksVCXVQENPxwTfQdH4= +go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= -go.uber.org/zap v1.19.0 h1:mZQZefskPPCMIBCSEH0v2/iUqqLrYtaeqwD6FUGUnFE= -go.uber.org/zap v1.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= +go.uber.org/zap v1.19.1 h1:ue41HOKd1vGURxrmeKIgELGb3jPW9DMUDGtsinblHwI= +go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -629,7 +629,6 @@ golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgw golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -664,8 +663,9 @@ golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.1.2 h1:kRBLX7v7Af8W7Gdbbc908OJcdgtK8bOz9Uaj8/F1ACA= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 289cab080424414ea9074ed3b938a7861a3f5743 Mon Sep 17 00:00:00 2001 From: Masayuki Morita Date: Wed, 15 Sep 2021 07:31:45 +0900 Subject: [PATCH 37/53] Add the `branch` key in the reference for server side repo config (#1784) Fixes #1695 The branch matcher feature has been implemented in #1383 and #1768. There is only an example for it, but not in the reference. https://github.com/runatlantis/atlantis/pull/1383/files#diff-5dd8dd3b7c37191b78109efaaa1bb73184ff7a1690632d687fed7cd748847f5eR31-R34 Add missing the `branch` key in the reference for server side repo config. I also add a warning for `mergeable` requirement to check the `branch` setting because I think a typical branch protection rule only restricts a default branch. We should let users know that someone can potentially bypass it without the `branch` restriction in atlantis. --- runatlantis.io/docs/apply-requirements.md | 7 +++++++ runatlantis.io/docs/server-side-repo-config.md | 2 ++ 2 files changed, 9 insertions(+) diff --git a/runatlantis.io/docs/apply-requirements.md b/runatlantis.io/docs/apply-requirements.md index 63ec3fe736..d1dc6787be 100644 --- a/runatlantis.io/docs/apply-requirements.md +++ b/runatlantis.io/docs/apply-requirements.md @@ -87,6 +87,13 @@ You can set the `mergeable` requirement by: #### Meaning Each VCS provider has a different concept of "mergeability": + +::: warning +Some VCS providers have a feature for branch protection to control "mergeability". If you want to use it, +you probably need to limit the base branch not to bypass the branch protection. +See also the `branch` keyword in [Server Side Repo Config](server-side-repo-config.html#reference) for more details. +::: + #### GitHub In GitHub, if you're not using [Protected Branches](https://help.github.com/articles/about-protected-branches/) then all pull requests are mergeable unless there is a conflict. diff --git a/runatlantis.io/docs/server-side-repo-config.md b/runatlantis.io/docs/server-side-repo-config.md index 0e2b3d4d44..b9a2b61677 100644 --- a/runatlantis.io/docs/server-side-repo-config.md +++ b/runatlantis.io/docs/server-side-repo-config.md @@ -348,6 +348,7 @@ custom workflows. ```yaml repos: - id: /.*/ + branch: /.*/ apply_requirements: [] workflow: default allowed_overrides: [] @@ -373,6 +374,7 @@ If you set a workflow with the key `default`, it will override this. | Key | Type | Default | Required | Description | |-------------------------------|----------|---------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | id | string | none | yes | Value can be a regular expression when specified as /<regex>/ or an exact string match. Repo IDs are of the form `{vcs hostname}/{org}/{name}`, ex. `github.com/owner/repo`. Hostname is specified without scheme or port. For Bitbucket Server, {org} is the **name** of the project, not the key. | +| branch | string | none | no | An regex matching pull requests by base branch (the branch the pull request is getting merged into). By default, all branches are matched | | workflow | string | none | no | A custom workflow. | | apply_requirements | []string | none | no | Requirements that must be satisfied before `atlantis apply` can be run. Currently the only supported requirements are `approved` and `mergeable`. See [Apply Requirements](apply-requirements.html) for more details. | | allowed_overrides | []string | none | no | A list of restricted keys that `atlantis.yaml` files can override. The only supported keys are `apply_requirements`, `workflow` and `delete_source_branch_on_merge` | From bf63dde18b275cbc6b3150004d65c8943a9aeeb5 Mon Sep 17 00:00:00 2001 From: rui Date: Wed, 15 Sep 2021 17:15:53 -0400 Subject: [PATCH 38/53] build: tf 1.0.7 (#1811) Signed-off-by: Rui Chen --- .circleci/config.yml | 2 +- Dockerfile | 2 +- testing/Dockerfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9dd997cdf0..a70a09af7c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,7 +16,7 @@ jobs: # We do this instead of setting --default-tf-version because setting # that flag starts the download asynchronously so we'd have a race # condition. - TERRAFORM_VERSION: 1.0.6 + TERRAFORM_VERSION: 1.0.7 steps: - checkout - run: make build-service diff --git a/Dockerfile b/Dockerfile index 5af6c55b6b..d037ce48aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM ghcr.io/runatlantis/atlantis-base:2021.08.31 # install terraform binaries -ENV DEFAULT_TERRAFORM_VERSION=1.0.6 +ENV DEFAULT_TERRAFORM_VERSION=1.0.7 # In the official Atlantis image we only have the latest of each Terraform version. RUN AVAILABLE_TERRAFORM_VERSIONS="0.8.8 0.9.11 0.10.8 0.11.15 0.12.31 0.13.7 0.14.11 0.15.5 ${DEFAULT_TERRAFORM_VERSION}" && \ diff --git a/testing/Dockerfile b/testing/Dockerfile index dad46be829..7869ce256f 100644 --- a/testing/Dockerfile +++ b/testing/Dockerfile @@ -1,7 +1,7 @@ FROM circleci/golang:1.17 # Install Terraform -ENV TERRAFORM_VERSION=1.0.6 +ENV TERRAFORM_VERSION=1.0.7 RUN curl -LOks https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip && \ sudo mkdir -p /usr/local/bin/tf/versions/${TERRAFORM_VERSION} && \ sudo unzip terraform_${TERRAFORM_VERSION}_linux_amd64.zip -d /usr/local/bin/tf/versions/${TERRAFORM_VERSION} && \ From b3af64a39c94483e17fefcaffa78ecf6619479f0 Mon Sep 17 00:00:00 2001 From: rui Date: Sun, 19 Sep 2021 00:29:38 -0400 Subject: [PATCH 39/53] deps: conftest 0.28.0 (#1819) Signed-off-by: Rui Chen --- Dockerfile.dev | 2 +- testing/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.dev b/Dockerfile.dev index 7726bb08d0..a0ff840d62 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,6 +1,6 @@ FROM ghcr.io/runatlantis/atlantis:latest COPY atlantis /usr/local/bin/atlantis # TODO: remove this once we get this in the base image -ENV DEFAULT_CONFTEST_VERSION=0.27.0 +ENV DEFAULT_CONFTEST_VERSION=0.28.0 WORKDIR /atlantis/src diff --git a/testing/Dockerfile b/testing/Dockerfile index 7869ce256f..2634bc7593 100644 --- a/testing/Dockerfile +++ b/testing/Dockerfile @@ -9,7 +9,7 @@ RUN curl -LOks https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/ter rm terraform_${TERRAFORM_VERSION}_linux_amd64.zip # Install conftest -ENV CONFTEST_VERSION=0.27.0 +ENV CONFTEST_VERSION=0.28.0 RUN curl -LOs https://github.com/open-policy-agent/conftest/releases/download/v${CONFTEST_VERSION}/conftest_${CONFTEST_VERSION}_Linux_x86_64.tar.gz && \ curl -LOs https://github.com/open-policy-agent/conftest/releases/download/v${CONFTEST_VERSION}/checksums.txt && \ sed -n "/conftest_${CONFTEST_VERSION}_Linux_x86_64.tar.gz/p" checksums.txt | sha256sum -c && \ From e050a356a0774a6556b06c8c931206906217ddb3 Mon Sep 17 00:00:00 2001 From: rui Date: Wed, 22 Sep 2021 13:29:30 -0400 Subject: [PATCH 40/53] deps: conftest 0.28.1 (#1826) --- Dockerfile.dev | 2 +- testing/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.dev b/Dockerfile.dev index a0ff840d62..19217625af 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,6 +1,6 @@ FROM ghcr.io/runatlantis/atlantis:latest COPY atlantis /usr/local/bin/atlantis # TODO: remove this once we get this in the base image -ENV DEFAULT_CONFTEST_VERSION=0.28.0 +ENV DEFAULT_CONFTEST_VERSION=0.28.1 WORKDIR /atlantis/src diff --git a/testing/Dockerfile b/testing/Dockerfile index 2634bc7593..235c5dd44d 100644 --- a/testing/Dockerfile +++ b/testing/Dockerfile @@ -9,7 +9,7 @@ RUN curl -LOks https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/ter rm terraform_${TERRAFORM_VERSION}_linux_amd64.zip # Install conftest -ENV CONFTEST_VERSION=0.28.0 +ENV CONFTEST_VERSION=0.28.1 RUN curl -LOs https://github.com/open-policy-agent/conftest/releases/download/v${CONFTEST_VERSION}/conftest_${CONFTEST_VERSION}_Linux_x86_64.tar.gz && \ curl -LOs https://github.com/open-policy-agent/conftest/releases/download/v${CONFTEST_VERSION}/checksums.txt && \ sed -n "/conftest_${CONFTEST_VERSION}_Linux_x86_64.tar.gz/p" checksums.txt | sha256sum -c && \ From afc170ce21148fb6398e0a7d86d40ee1aad5a4cc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 22 Sep 2021 14:17:30 -0400 Subject: [PATCH 41/53] build(deps): bump prismjs from 1.24.0 to 1.25.0 (#1823) Bumps [prismjs](https://github.com/PrismJS/prism) from 1.24.0 to 1.25.0. - [Release notes](https://github.com/PrismJS/prism/releases) - [Changelog](https://github.com/PrismJS/prism/blob/master/CHANGELOG.md) - [Commits](https://github.com/PrismJS/prism/compare/v1.24.0...v1.25.0) --- updated-dependencies: - dependency-name: prismjs dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yarn.lock b/yarn.lock index f32f477d28..49d3d1f92b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4564,8 +4564,8 @@ pretty-time@^1.0.0: nanoseconds "^1.0.0" prismjs@^1.13.0: - version "1.24.0" - resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.24.0.tgz#0409c30068a6c52c89ef7f1089b3ca4de56be2ac" + version "1.25.0" + resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.25.0.tgz#6f822df1bdad965734b310b315a23315cf999756" private@^0.1.6: version "0.1.8" From bb2c239dd9f3475fc06e4b703c6ccc064874a150 Mon Sep 17 00:00:00 2001 From: Aayush Gupta <43479002+Aayyush@users.noreply.github.com> Date: Wed, 22 Sep 2021 12:41:05 -0700 Subject: [PATCH 42/53] Updating client interface and adding ApprovalStatus model (#1827) --- .../events/events_controller_e2e_test.go | 4 +- .../mocks/matchers/models_approvalstatus.go | 33 ++ .../mocks/mock_pull_approved_checker.go | 18 +- server/core/runtime/pull_approved_checker.go | 2 +- server/events/apply_requirement_handler.go | 4 +- server/events/command_context.go | 3 + server/events/models/models.go | 12 + server/events/project_command_runner_test.go | 8 +- server/events/vcs/azuredevops_client.go | 10 +- server/events/vcs/azuredevops_client_test.go | 4 +- server/events/vcs/bitbucketcloud/client.go | 14 +- .../events/vcs/bitbucketcloud/client_test.go | 4 +- server/events/vcs/bitbucketserver/client.go | 16 +- server/events/vcs/client.go | 2 +- server/events/vcs/github_client.go | 12 +- server/events/vcs/github_client_test.go | 4 +- server/events/vcs/gitlab_client.go | 10 +- .../mocks/matchers/models_approvalstatus.go | 33 ++ server/events/vcs/mocks/mock_client.go | 404 +++++++++--------- .../events/vcs/not_configured_vcs_client.go | 4 +- server/events/vcs/proxy.go | 2 +- 21 files changed, 351 insertions(+), 252 deletions(-) create mode 100644 server/core/runtime/mocks/matchers/models_approvalstatus.go create mode 100644 server/events/vcs/mocks/matchers/models_approvalstatus.go diff --git a/server/controllers/events/events_controller_e2e_test.go b/server/controllers/events/events_controller_e2e_test.go index fd0c6adfe1..06db9b5045 100644 --- a/server/controllers/events/events_controller_e2e_test.go +++ b/server/controllers/events/events_controller_e2e_test.go @@ -734,7 +734,9 @@ func TestGitHubWorkflowWithPolicyCheck(t *testing.T) { // Setup test dependencies. w := httptest.NewRecorder() When(vcsClient.PullIsMergeable(AnyRepo(), matchers.AnyModelsPullRequest())).ThenReturn(true, nil) - When(vcsClient.PullIsApproved(AnyRepo(), matchers.AnyModelsPullRequest())).ThenReturn(true, nil) + When(vcsClient.PullIsApproved(AnyRepo(), matchers.AnyModelsPullRequest())).ThenReturn(models.ApprovalStatus{ + IsApproved: true, + }, nil) When(githubGetter.GetPullRequest(AnyRepo(), AnyInt())).ThenReturn(GitHubPullRequestParsed(headSHA), nil) When(vcsClient.GetModifiedFiles(AnyRepo(), matchers.AnyModelsPullRequest())).ThenReturn(c.ModifiedFiles, nil) diff --git a/server/core/runtime/mocks/matchers/models_approvalstatus.go b/server/core/runtime/mocks/matchers/models_approvalstatus.go new file mode 100644 index 0000000000..01b76dd968 --- /dev/null +++ b/server/core/runtime/mocks/matchers/models_approvalstatus.go @@ -0,0 +1,33 @@ +// Code generated by pegomock. DO NOT EDIT. +package matchers + +import ( + "github.com/petergtz/pegomock" + "reflect" + + models "github.com/runatlantis/atlantis/server/events/models" +) + +func AnyModelsApprovalStatus() models.ApprovalStatus { + pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(models.ApprovalStatus))(nil)).Elem())) + var nullValue models.ApprovalStatus + return nullValue +} + +func EqModelsApprovalStatus(value models.ApprovalStatus) models.ApprovalStatus { + pegomock.RegisterMatcher(&pegomock.EqMatcher{Value: value}) + var nullValue models.ApprovalStatus + return nullValue +} + +func NotEqModelsApprovalStatus(value models.ApprovalStatus) models.ApprovalStatus { + pegomock.RegisterMatcher(&pegomock.NotEqMatcher{Value: value}) + var nullValue models.ApprovalStatus + return nullValue +} + +func ModelsApprovalStatusThat(matcher pegomock.ArgumentMatcher) models.ApprovalStatus { + pegomock.RegisterMatcher(matcher) + var nullValue models.ApprovalStatus + return nullValue +} diff --git a/server/core/runtime/mocks/mock_pull_approved_checker.go b/server/core/runtime/mocks/mock_pull_approved_checker.go index 9c07901003..a71dd3506c 100644 --- a/server/core/runtime/mocks/mock_pull_approved_checker.go +++ b/server/core/runtime/mocks/mock_pull_approved_checker.go @@ -25,17 +25,17 @@ func NewMockPullApprovedChecker(options ...pegomock.Option) *MockPullApprovedChe func (mock *MockPullApprovedChecker) SetFailHandler(fh pegomock.FailHandler) { mock.fail = fh } func (mock *MockPullApprovedChecker) FailHandler() pegomock.FailHandler { return mock.fail } -func (mock *MockPullApprovedChecker) PullIsApproved(baseRepo models.Repo, pull models.PullRequest) (bool, error) { +func (mock *MockPullApprovedChecker) PullIsApproved(_param0 models.Repo, _param1 models.PullRequest) (models.ApprovalStatus, error) { if mock == nil { panic("mock must not be nil. Use myMock := NewMockPullApprovedChecker().") } - params := []pegomock.Param{baseRepo, pull} - result := pegomock.GetGenericMockFrom(mock).Invoke("PullIsApproved", params, []reflect.Type{reflect.TypeOf((*bool)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()}) - var ret0 bool + params := []pegomock.Param{_param0, _param1} + result := pegomock.GetGenericMockFrom(mock).Invoke("PullIsApproved", params, []reflect.Type{reflect.TypeOf((*models.ApprovalStatus)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()}) + var ret0 models.ApprovalStatus var ret1 error if len(result) != 0 { if result[0] != nil { - ret0 = result[0].(bool) + ret0 = result[0].(models.ApprovalStatus) } if result[1] != nil { ret1 = result[1].(error) @@ -81,8 +81,8 @@ type VerifierMockPullApprovedChecker struct { timeout time.Duration } -func (verifier *VerifierMockPullApprovedChecker) PullIsApproved(baseRepo models.Repo, pull models.PullRequest) *MockPullApprovedChecker_PullIsApproved_OngoingVerification { - params := []pegomock.Param{baseRepo, pull} +func (verifier *VerifierMockPullApprovedChecker) PullIsApproved(_param0 models.Repo, _param1 models.PullRequest) *MockPullApprovedChecker_PullIsApproved_OngoingVerification { + params := []pegomock.Param{_param0, _param1} methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "PullIsApproved", params, verifier.timeout) return &MockPullApprovedChecker_PullIsApproved_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} } @@ -93,8 +93,8 @@ type MockPullApprovedChecker_PullIsApproved_OngoingVerification struct { } func (c *MockPullApprovedChecker_PullIsApproved_OngoingVerification) GetCapturedArguments() (models.Repo, models.PullRequest) { - baseRepo, pull := c.GetAllCapturedArguments() - return baseRepo[len(baseRepo)-1], pull[len(pull)-1] + _param0, _param1 := c.GetAllCapturedArguments() + return _param0[len(_param0)-1], _param1[len(_param1)-1] } func (c *MockPullApprovedChecker_PullIsApproved_OngoingVerification) GetAllCapturedArguments() (_param0 []models.Repo, _param1 []models.PullRequest) { diff --git a/server/core/runtime/pull_approved_checker.go b/server/core/runtime/pull_approved_checker.go index e77aa2acb1..ade67c9923 100644 --- a/server/core/runtime/pull_approved_checker.go +++ b/server/core/runtime/pull_approved_checker.go @@ -7,5 +7,5 @@ import ( //go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_pull_approved_checker.go PullApprovedChecker type PullApprovedChecker interface { - PullIsApproved(baseRepo models.Repo, pull models.PullRequest) (bool, error) + PullIsApproved(baseRepo models.Repo, pull models.PullRequest) (models.ApprovalStatus, error) } diff --git a/server/events/apply_requirement_handler.go b/server/events/apply_requirement_handler.go index bd0c8051f2..cec45ca4d7 100644 --- a/server/events/apply_requirement_handler.go +++ b/server/events/apply_requirement_handler.go @@ -23,11 +23,11 @@ func (a *AggregateApplyRequirements) ValidateProject(repoDir string, ctx models. for _, req := range ctx.ApplyRequirements { switch req { case raw.ApprovedApplyRequirement: - approved, err := a.PullApprovedChecker.PullIsApproved(ctx.Pull.BaseRepo, ctx.Pull) // nolint: vetshadow + approvalStatus, err := a.PullApprovedChecker.PullIsApproved(ctx.Pull.BaseRepo, ctx.Pull) // nolint: vetshadow if err != nil { return "", errors.Wrap(err, "checking if pull request was approved") } - if !approved { + if !approvalStatus.IsApproved { return "Pull request must be approved by at least one person other than the author before running apply.", nil } // this should come before mergeability check since mergeability is a superset of this check. diff --git a/server/events/command_context.go b/server/events/command_context.go index a4d6ebb13a..6e9228b969 100644 --- a/server/events/command_context.go +++ b/server/events/command_context.go @@ -46,6 +46,9 @@ type CommandContext struct { // required the Atlantis status to be successful prior to merging. PullMergeable bool + // Current PR state + PullRequestStatus models.PullReqStatus + PullStatus *models.PullStatus Trigger CommandTrigger diff --git a/server/events/models/models.go b/server/events/models/models.go index fb66ac1230..edc389bfd8 100644 --- a/server/events/models/models.go +++ b/server/events/models/models.go @@ -142,6 +142,16 @@ func NewRepo(vcsHostType VCSHostType, repoFullName string, cloneURL string, vcsU }, nil } +type PullReqStatus struct { + Approved ApprovalStatus +} + +type ApprovalStatus struct { + IsApproved bool + ApprovedBy string + Date time.Time +} + // PullRequest is a VCS pull request. // GitLab calls these Merge Requests. type PullRequest struct { @@ -367,6 +377,8 @@ type ProjectCommandContext struct { // PullMergeable is true if the pull request for this project is able to be merged. PullMergeable bool // CurrentProjectPlanStatus is the status of the current project prior to this command. + PullReqStatus PullReqStatus + // CurrentProjectPlanStatus is the status of the current project prior to this command. ProjectPlanStatus ProjectPlanStatus // Pull is the pull request we're responding to. Pull PullRequest diff --git a/server/events/project_command_runner_test.go b/server/events/project_command_runner_test.go index de255c4827..92f28ffa5a 100644 --- a/server/events/project_command_runner_test.go +++ b/server/events/project_command_runner_test.go @@ -162,7 +162,9 @@ func TestDefaultProjectCommandRunner_ApplyNotApproved(t *testing.T) { tmp, cleanup := TempDir(t) defer cleanup() When(mockWorkingDir.GetWorkingDir(ctx.BaseRepo, ctx.Pull, ctx.Workspace)).ThenReturn(tmp, nil) - When(mockApproved.PullIsApproved(ctx.BaseRepo, ctx.Pull)).ThenReturn(false, nil) + When(mockApproved.PullIsApproved(ctx.BaseRepo, ctx.Pull)).ThenReturn(models.ApprovalStatus{ + IsApproved: false, + }, nil) res := runner.Apply(ctx) Equals(t, "Pull request must be approved by at least one person other than the author before running apply.", res.Failure) @@ -346,7 +348,9 @@ func TestDefaultProjectCommandRunner_Apply(t *testing.T) { When(mockApply.Run(ctx, nil, repoDir, expEnvs)).ThenReturn("apply", nil) When(mockRun.Run(ctx, "", repoDir, expEnvs)).ThenReturn("run", nil) When(mockEnv.Run(ctx, "", "value", repoDir, make(map[string]string))).ThenReturn("value", nil) - When(mockApproved.PullIsApproved(ctx.BaseRepo, ctx.Pull)).ThenReturn(true, nil) + When(mockApproved.PullIsApproved(ctx.BaseRepo, ctx.Pull)).ThenReturn(models.ApprovalStatus{ + IsApproved: true, + }, nil) res := runner.Apply(ctx) Equals(t, c.expOut, res.ApplySuccess) diff --git a/server/events/vcs/azuredevops_client.go b/server/events/vcs/azuredevops_client.go index 2989544ab7..2369048b4b 100644 --- a/server/events/vcs/azuredevops_client.go +++ b/server/events/vcs/azuredevops_client.go @@ -136,7 +136,7 @@ func (g *AzureDevopsClient) HidePrevCommandComments(repo models.Repo, pullNum in // PullIsApproved returns true if the merge request was approved by another reviewer. // https://docs.microsoft.com/en-us/azure/devops/repos/git/branch-policies?view=azure-devops#require-a-minimum-number-of-reviewers -func (g *AzureDevopsClient) PullIsApproved(repo models.Repo, pull models.PullRequest) (bool, error) { +func (g *AzureDevopsClient) PullIsApproved(repo models.Repo, pull models.PullRequest) (approvalStatus models.ApprovalStatus, err error) { owner, project, repoName := SplitAzureDevopsRepoFullName(repo.FullName) opts := azuredevops.PullRequestGetOptions{ @@ -144,7 +144,7 @@ func (g *AzureDevopsClient) PullIsApproved(repo models.Repo, pull models.PullReq } adPull, _, err := g.Client.PullRequests.GetWithRepo(g.ctx, owner, project, repoName, pull.Num, &opts) if err != nil { - return false, errors.Wrap(err, "getting pull request") + return approvalStatus, errors.Wrap(err, "getting pull request") } for _, review := range adPull.Reviewers { @@ -157,11 +157,13 @@ func (g *AzureDevopsClient) PullIsApproved(repo models.Repo, pull models.PullReq } if review.GetVote() == azuredevops.VoteApproved || review.GetVote() == azuredevops.VoteApprovedWithSuggestions { - return true, nil + return models.ApprovalStatus{ + IsApproved: true, + }, nil } } - return false, nil + return approvalStatus, nil } // PullIsMergeable returns true if the merge request can be merged. diff --git a/server/events/vcs/azuredevops_client_test.go b/server/events/vcs/azuredevops_client_test.go index 0b30a77526..d7c40ee6c5 100644 --- a/server/events/vcs/azuredevops_client_test.go +++ b/server/events/vcs/azuredevops_client_test.go @@ -495,7 +495,7 @@ func TestAzureDevopsClient_PullIsApproved(t *testing.T) { defer disableSSLVerification()() - actApproved, err := client.PullIsApproved(models.Repo{ + approvalStatus, err := client.PullIsApproved(models.Repo{ FullName: "owner/project/repo", Owner: "owner", Name: "repo", @@ -509,7 +509,7 @@ func TestAzureDevopsClient_PullIsApproved(t *testing.T) { Num: 1, }) Ok(t, err) - Equals(t, c.expApproved, actApproved) + Equals(t, c.expApproved, approvalStatus.IsApproved) }) } } diff --git a/server/events/vcs/bitbucketcloud/client.go b/server/events/vcs/bitbucketcloud/client.go index 9ba1ca41ee..979fcdc560 100644 --- a/server/events/vcs/bitbucketcloud/client.go +++ b/server/events/vcs/bitbucketcloud/client.go @@ -105,28 +105,30 @@ func (b *Client) HidePrevCommandComments(repo models.Repo, pullNum int, command } // PullIsApproved returns true if the merge request was approved. -func (b *Client) PullIsApproved(repo models.Repo, pull models.PullRequest) (bool, error) { +func (b *Client) PullIsApproved(repo models.Repo, pull models.PullRequest) (approvalStatus models.ApprovalStatus, err error) { path := fmt.Sprintf("%s/2.0/repositories/%s/pullrequests/%d", b.BaseURL, repo.FullName, pull.Num) resp, err := b.makeRequest("GET", path, nil) if err != nil { - return false, err + return approvalStatus, err } var pullResp PullRequest if err := json.Unmarshal(resp, &pullResp); err != nil { - return false, errors.Wrapf(err, "Could not parse response %q", string(resp)) + return approvalStatus, errors.Wrapf(err, "Could not parse response %q", string(resp)) } if err := validator.New().Struct(pullResp); err != nil { - return false, errors.Wrapf(err, "API response %q was missing fields", string(resp)) + return approvalStatus, errors.Wrapf(err, "API response %q was missing fields", string(resp)) } authorUUID := *pullResp.Author.UUID for _, participant := range pullResp.Participants { // Bitbucket allows the author to approve their own pull request. This // defeats the purpose of approvals so we don't count that approval. if *participant.Approved && *participant.User.UUID != authorUUID { - return true, nil + return models.ApprovalStatus{ + IsApproved: true, + }, nil } } - return false, nil + return approvalStatus, nil } // PullIsMergeable returns true if the merge request has no conflicts and can be merged. diff --git a/server/events/vcs/bitbucketcloud/client_test.go b/server/events/vcs/bitbucketcloud/client_test.go index 0575e9e8ee..b14c54894c 100644 --- a/server/events/vcs/bitbucketcloud/client_test.go +++ b/server/events/vcs/bitbucketcloud/client_test.go @@ -202,14 +202,14 @@ func TestClient_PullIsApproved(t *testing.T) { repo, err := models.NewRepo(models.BitbucketServer, "owner/repo", "https://bitbucket.org/owner/repo.git", "user", "token") Ok(t, err) - approved, err := client.PullIsApproved(repo, models.PullRequest{ + approvalStatus, err := client.PullIsApproved(repo, models.PullRequest{ Num: 1, HeadBranch: "branch", Author: "author", BaseRepo: repo, }) Ok(t, err) - Equals(t, c.exp, approved) + Equals(t, c.exp, approvalStatus.IsApproved) }) } } diff --git a/server/events/vcs/bitbucketserver/client.go b/server/events/vcs/bitbucketserver/client.go index 27af85354d..fa23c3d07c 100644 --- a/server/events/vcs/bitbucketserver/client.go +++ b/server/events/vcs/bitbucketserver/client.go @@ -161,29 +161,31 @@ func (b *Client) postComment(repo models.Repo, pullNum int, comment string) erro } // PullIsApproved returns true if the merge request was approved. -func (b *Client) PullIsApproved(repo models.Repo, pull models.PullRequest) (bool, error) { +func (b *Client) PullIsApproved(repo models.Repo, pull models.PullRequest) (approvalStatus models.ApprovalStatus, err error) { projectKey, err := b.GetProjectKey(repo.Name, repo.SanitizedCloneURL) if err != nil { - return false, err + return approvalStatus, err } path := fmt.Sprintf("%s/rest/api/1.0/projects/%s/repos/%s/pull-requests/%d", b.BaseURL, projectKey, repo.Name, pull.Num) resp, err := b.makeRequest("GET", path, nil) if err != nil { - return false, err + return approvalStatus, err } var pullResp PullRequest if err := json.Unmarshal(resp, &pullResp); err != nil { - return false, errors.Wrapf(err, "Could not parse response %q", string(resp)) + return approvalStatus, errors.Wrapf(err, "Could not parse response %q", string(resp)) } if err := validator.New().Struct(pullResp); err != nil { - return false, errors.Wrapf(err, "API response %q was missing fields", string(resp)) + return approvalStatus, errors.Wrapf(err, "API response %q was missing fields", string(resp)) } for _, reviewer := range pullResp.Reviewers { if *reviewer.Approved { - return true, nil + return models.ApprovalStatus{ + IsApproved: true, + }, nil } } - return false, nil + return approvalStatus, nil } // PullIsMergeable returns true if the merge request has no conflicts and can be merged. diff --git a/server/events/vcs/client.go b/server/events/vcs/client.go index 0f49cc89de..711e558204 100644 --- a/server/events/vcs/client.go +++ b/server/events/vcs/client.go @@ -26,7 +26,7 @@ type Client interface { GetModifiedFiles(repo models.Repo, pull models.PullRequest) ([]string, error) CreateComment(repo models.Repo, pullNum int, comment string, command string) error HidePrevCommandComments(repo models.Repo, pullNum int, command string) error - PullIsApproved(repo models.Repo, pull models.PullRequest) (bool, error) + PullIsApproved(repo models.Repo, pull models.PullRequest) (models.ApprovalStatus, error) PullIsMergeable(repo models.Repo, pull models.PullRequest) (bool, error) // UpdateStatus updates the commit status to state for pull. src is the // source of this status. This should be relatively static across runs, diff --git a/server/events/vcs/github_client.go b/server/events/vcs/github_client.go index 6079fe408c..f55a9e7882 100644 --- a/server/events/vcs/github_client.go +++ b/server/events/vcs/github_client.go @@ -232,7 +232,7 @@ func (g *GithubClient) HidePrevCommandComments(repo models.Repo, pullNum int, co } // PullIsApproved returns true if the pull request was approved. -func (g *GithubClient) PullIsApproved(repo models.Repo, pull models.PullRequest) (bool, error) { +func (g *GithubClient) PullIsApproved(repo models.Repo, pull models.PullRequest) (approvalStatus models.ApprovalStatus, err error) { nextPage := 0 for { opts := github.ListOptions{ @@ -244,11 +244,15 @@ func (g *GithubClient) PullIsApproved(repo models.Repo, pull models.PullRequest) g.logger.Debug("GET /repos/%v/%v/pulls/%d/reviews", repo.Owner, repo.Name, pull.Num) pageReviews, resp, err := g.client.PullRequests.ListReviews(g.ctx, repo.Owner, repo.Name, pull.Num, &opts) if err != nil { - return false, errors.Wrap(err, "getting reviews") + return approvalStatus, errors.Wrap(err, "getting reviews") } for _, review := range pageReviews { if review != nil && review.GetState() == "APPROVED" { - return true, nil + return models.ApprovalStatus{ + IsApproved: true, + ApprovedBy: *review.User.Login, + Date: *review.SubmittedAt, + }, nil } } if resp.NextPage == 0 { @@ -256,7 +260,7 @@ func (g *GithubClient) PullIsApproved(repo models.Repo, pull models.PullRequest) } nextPage = resp.NextPage } - return false, nil + return approvalStatus, nil } // PullIsMergeable returns true if the pull request is mergeable. diff --git a/server/events/vcs/github_client_test.go b/server/events/vcs/github_client_test.go index 115902dd88..9d90e268be 100644 --- a/server/events/vcs/github_client_test.go +++ b/server/events/vcs/github_client_test.go @@ -455,7 +455,7 @@ func TestGithubClient_PullIsApproved(t *testing.T) { Ok(t, err) defer disableSSLVerification()() - approved, err := client.PullIsApproved(models.Repo{ + approvalStatus, err := client.PullIsApproved(models.Repo{ FullName: "owner/repo", Owner: "owner", Name: "repo", @@ -469,7 +469,7 @@ func TestGithubClient_PullIsApproved(t *testing.T) { Num: 1, }) Ok(t, err) - Equals(t, false, approved) + Equals(t, false, approvalStatus.IsApproved) } func TestGithubClient_PullIsMergeable(t *testing.T) { diff --git a/server/events/vcs/gitlab_client.go b/server/events/vcs/gitlab_client.go index 07e26df88d..7d380735a6 100644 --- a/server/events/vcs/gitlab_client.go +++ b/server/events/vcs/gitlab_client.go @@ -168,15 +168,17 @@ func (g *GitlabClient) HidePrevCommandComments(repo models.Repo, pullNum int, co } // PullIsApproved returns true if the merge request was approved. -func (g *GitlabClient) PullIsApproved(repo models.Repo, pull models.PullRequest) (bool, error) { +func (g *GitlabClient) PullIsApproved(repo models.Repo, pull models.PullRequest) (approvalStatus models.ApprovalStatus, err error) { approvals, _, err := g.Client.MergeRequests.GetMergeRequestApprovals(repo.FullName, pull.Num) if err != nil { - return false, err + return approvalStatus, err } if approvals.ApprovalsLeft > 0 { - return false, nil + return approvalStatus, nil } - return true, nil + return models.ApprovalStatus{ + IsApproved: true, + }, nil } // PullIsMergeable returns true if the merge request can be merged. diff --git a/server/events/vcs/mocks/matchers/models_approvalstatus.go b/server/events/vcs/mocks/matchers/models_approvalstatus.go new file mode 100644 index 0000000000..01b76dd968 --- /dev/null +++ b/server/events/vcs/mocks/matchers/models_approvalstatus.go @@ -0,0 +1,33 @@ +// Code generated by pegomock. DO NOT EDIT. +package matchers + +import ( + "github.com/petergtz/pegomock" + "reflect" + + models "github.com/runatlantis/atlantis/server/events/models" +) + +func AnyModelsApprovalStatus() models.ApprovalStatus { + pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(models.ApprovalStatus))(nil)).Elem())) + var nullValue models.ApprovalStatus + return nullValue +} + +func EqModelsApprovalStatus(value models.ApprovalStatus) models.ApprovalStatus { + pegomock.RegisterMatcher(&pegomock.EqMatcher{Value: value}) + var nullValue models.ApprovalStatus + return nullValue +} + +func NotEqModelsApprovalStatus(value models.ApprovalStatus) models.ApprovalStatus { + pegomock.RegisterMatcher(&pegomock.NotEqMatcher{Value: value}) + var nullValue models.ApprovalStatus + return nullValue +} + +func ModelsApprovalStatusThat(matcher pegomock.ArgumentMatcher) models.ApprovalStatus { + pegomock.RegisterMatcher(matcher) + var nullValue models.ApprovalStatus + return nullValue +} diff --git a/server/events/vcs/mocks/mock_client.go b/server/events/vcs/mocks/mock_client.go index a39dd61e45..38123421bb 100644 --- a/server/events/vcs/mocks/mock_client.go +++ b/server/events/vcs/mocks/mock_client.go @@ -25,30 +25,11 @@ func NewMockClient(options ...pegomock.Option) *MockClient { func (mock *MockClient) SetFailHandler(fh pegomock.FailHandler) { mock.fail = fh } func (mock *MockClient) FailHandler() pegomock.FailHandler { return mock.fail } -func (mock *MockClient) GetModifiedFiles(repo models.Repo, pull models.PullRequest) ([]string, error) { +func (mock *MockClient) CreateComment(_param0 models.Repo, _param1 int, _param2 string, _param3 string) error { if mock == nil { panic("mock must not be nil. Use myMock := NewMockClient().") } - params := []pegomock.Param{repo, pull} - result := pegomock.GetGenericMockFrom(mock).Invoke("GetModifiedFiles", params, []reflect.Type{reflect.TypeOf((*[]string)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()}) - var ret0 []string - var ret1 error - if len(result) != 0 { - if result[0] != nil { - ret0 = result[0].([]string) - } - if result[1] != nil { - ret1 = result[1].(error) - } - } - return ret0, ret1 -} - -func (mock *MockClient) CreateComment(repo models.Repo, pullNum int, comment string, command string) error { - if mock == nil { - panic("mock must not be nil. Use myMock := NewMockClient().") - } - params := []pegomock.Param{repo, pullNum, comment, command} + params := []pegomock.Param{_param0, _param1, _param2, _param3} result := pegomock.GetGenericMockFrom(mock).Invoke("CreateComment", params, []reflect.Type{reflect.TypeOf((*error)(nil)).Elem()}) var ret0 error if len(result) != 0 { @@ -59,32 +40,40 @@ func (mock *MockClient) CreateComment(repo models.Repo, pullNum int, comment str return ret0 } -func (mock *MockClient) HidePrevCommandComments(repo models.Repo, pullNum int, command string) error { +func (mock *MockClient) DownloadRepoConfigFile(_param0 models.PullRequest) (bool, []byte, error) { if mock == nil { panic("mock must not be nil. Use myMock := NewMockClient().") } - params := []pegomock.Param{repo, pullNum, command} - result := pegomock.GetGenericMockFrom(mock).Invoke("HidePrevCommandComments", params, []reflect.Type{reflect.TypeOf((*error)(nil)).Elem()}) - var ret0 error + params := []pegomock.Param{_param0} + result := pegomock.GetGenericMockFrom(mock).Invoke("DownloadRepoConfigFile", params, []reflect.Type{reflect.TypeOf((*bool)(nil)).Elem(), reflect.TypeOf((*[]byte)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()}) + var ret0 bool + var ret1 []byte + var ret2 error if len(result) != 0 { if result[0] != nil { - ret0 = result[0].(error) + ret0 = result[0].(bool) + } + if result[1] != nil { + ret1 = result[1].([]byte) + } + if result[2] != nil { + ret2 = result[2].(error) } } - return ret0 + return ret0, ret1, ret2 } -func (mock *MockClient) PullIsApproved(repo models.Repo, pull models.PullRequest) (bool, error) { +func (mock *MockClient) GetModifiedFiles(_param0 models.Repo, _param1 models.PullRequest) ([]string, error) { if mock == nil { panic("mock must not be nil. Use myMock := NewMockClient().") } - params := []pegomock.Param{repo, pull} - result := pegomock.GetGenericMockFrom(mock).Invoke("PullIsApproved", params, []reflect.Type{reflect.TypeOf((*bool)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()}) - var ret0 bool + params := []pegomock.Param{_param0, _param1} + result := pegomock.GetGenericMockFrom(mock).Invoke("GetModifiedFiles", params, []reflect.Type{reflect.TypeOf((*[]string)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()}) + var ret0 []string var ret1 error if len(result) != 0 { if result[0] != nil { - ret0 = result[0].(bool) + ret0 = result[0].([]string) } if result[1] != nil { ret1 = result[1].(error) @@ -93,45 +82,45 @@ func (mock *MockClient) PullIsApproved(repo models.Repo, pull models.PullRequest return ret0, ret1 } -func (mock *MockClient) PullIsMergeable(repo models.Repo, pull models.PullRequest) (bool, error) { +func (mock *MockClient) HidePrevCommandComments(_param0 models.Repo, _param1 int, _param2 string) error { if mock == nil { panic("mock must not be nil. Use myMock := NewMockClient().") } - params := []pegomock.Param{repo, pull} - result := pegomock.GetGenericMockFrom(mock).Invoke("PullIsMergeable", params, []reflect.Type{reflect.TypeOf((*bool)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()}) - var ret0 bool - var ret1 error + params := []pegomock.Param{_param0, _param1, _param2} + result := pegomock.GetGenericMockFrom(mock).Invoke("HidePrevCommandComments", params, []reflect.Type{reflect.TypeOf((*error)(nil)).Elem()}) + var ret0 error if len(result) != 0 { if result[0] != nil { - ret0 = result[0].(bool) - } - if result[1] != nil { - ret1 = result[1].(error) + ret0 = result[0].(error) } } - return ret0, ret1 + return ret0 } -func (mock *MockClient) UpdateStatus(repo models.Repo, pull models.PullRequest, state models.CommitStatus, src string, description string, url string) error { +func (mock *MockClient) MarkdownPullLink(_param0 models.PullRequest) (string, error) { if mock == nil { panic("mock must not be nil. Use myMock := NewMockClient().") } - params := []pegomock.Param{repo, pull, state, src, description, url} - result := pegomock.GetGenericMockFrom(mock).Invoke("UpdateStatus", params, []reflect.Type{reflect.TypeOf((*error)(nil)).Elem()}) - var ret0 error + params := []pegomock.Param{_param0} + result := pegomock.GetGenericMockFrom(mock).Invoke("MarkdownPullLink", params, []reflect.Type{reflect.TypeOf((*string)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()}) + var ret0 string + var ret1 error if len(result) != 0 { if result[0] != nil { - ret0 = result[0].(error) + ret0 = result[0].(string) + } + if result[1] != nil { + ret1 = result[1].(error) } } - return ret0 + return ret0, ret1 } -func (mock *MockClient) MergePull(pull models.PullRequest, pullOptions models.PullRequestOptions) error { +func (mock *MockClient) MergePull(_param0 models.PullRequest, _param1 models.PullRequestOptions) error { if mock == nil { panic("mock must not be nil. Use myMock := NewMockClient().") } - params := []pegomock.Param{pull, pullOptions} + params := []pegomock.Param{_param0, _param1} result := pegomock.GetGenericMockFrom(mock).Invoke("MergePull", params, []reflect.Type{reflect.TypeOf((*error)(nil)).Elem()}) var ret0 error if len(result) != 0 { @@ -142,17 +131,17 @@ func (mock *MockClient) MergePull(pull models.PullRequest, pullOptions models.Pu return ret0 } -func (mock *MockClient) MarkdownPullLink(pull models.PullRequest) (string, error) { +func (mock *MockClient) PullIsApproved(_param0 models.Repo, _param1 models.PullRequest) (models.ApprovalStatus, error) { if mock == nil { panic("mock must not be nil. Use myMock := NewMockClient().") } - params := []pegomock.Param{pull} - result := pegomock.GetGenericMockFrom(mock).Invoke("MarkdownPullLink", params, []reflect.Type{reflect.TypeOf((*string)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()}) - var ret0 string + params := []pegomock.Param{_param0, _param1} + result := pegomock.GetGenericMockFrom(mock).Invoke("PullIsApproved", params, []reflect.Type{reflect.TypeOf((*models.ApprovalStatus)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()}) + var ret0 models.ApprovalStatus var ret1 error if len(result) != 0 { if result[0] != nil { - ret0 = result[0].(string) + ret0 = result[0].(models.ApprovalStatus) } if result[1] != nil { ret1 = result[1].(error) @@ -161,34 +150,30 @@ func (mock *MockClient) MarkdownPullLink(pull models.PullRequest) (string, error return ret0, ret1 } -func (mock *MockClient) DownloadRepoConfigFile(pull models.PullRequest) (bool, []byte, error) { +func (mock *MockClient) PullIsMergeable(_param0 models.Repo, _param1 models.PullRequest) (bool, error) { if mock == nil { panic("mock must not be nil. Use myMock := NewMockClient().") } - params := []pegomock.Param{pull} - result := pegomock.GetGenericMockFrom(mock).Invoke("DownloadRepoConfigFile", params, []reflect.Type{reflect.TypeOf((*bool)(nil)).Elem(), reflect.TypeOf((*[]byte)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()}) + params := []pegomock.Param{_param0, _param1} + result := pegomock.GetGenericMockFrom(mock).Invoke("PullIsMergeable", params, []reflect.Type{reflect.TypeOf((*bool)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()}) var ret0 bool - var ret1 []byte - var ret2 error + var ret1 error if len(result) != 0 { if result[0] != nil { ret0 = result[0].(bool) } if result[1] != nil { - ret1 = result[1].([]byte) - } - if result[2] != nil { - ret2 = result[2].(error) + ret1 = result[1].(error) } } - return ret0, ret1, ret2 + return ret0, ret1 } -func (mock *MockClient) SupportsSingleFileDownload(repo models.Repo) bool { +func (mock *MockClient) SupportsSingleFileDownload(_param0 models.Repo) bool { if mock == nil { panic("mock must not be nil. Use myMock := NewMockClient().") } - params := []pegomock.Param{repo} + params := []pegomock.Param{_param0} result := pegomock.GetGenericMockFrom(mock).Invoke("SupportsSingleFileDownload", params, []reflect.Type{reflect.TypeOf((*bool)(nil)).Elem()}) var ret0 bool if len(result) != 0 { @@ -199,6 +184,21 @@ func (mock *MockClient) SupportsSingleFileDownload(repo models.Repo) bool { return ret0 } +func (mock *MockClient) UpdateStatus(_param0 models.Repo, _param1 models.PullRequest, _param2 models.CommitStatus, _param3 string, _param4 string, _param5 string) error { + if mock == nil { + panic("mock must not be nil. Use myMock := NewMockClient().") + } + params := []pegomock.Param{_param0, _param1, _param2, _param3, _param4, _param5} + result := pegomock.GetGenericMockFrom(mock).Invoke("UpdateStatus", params, []reflect.Type{reflect.TypeOf((*error)(nil)).Elem()}) + var ret0 error + if len(result) != 0 { + if result[0] != nil { + ret0 = result[0].(error) + } + } + return ret0 +} + func (mock *MockClient) VerifyWasCalledOnce() *VerifierMockClient { return &VerifierMockClient{ mock: mock, @@ -236,39 +236,8 @@ type VerifierMockClient struct { timeout time.Duration } -func (verifier *VerifierMockClient) GetModifiedFiles(repo models.Repo, pull models.PullRequest) *MockClient_GetModifiedFiles_OngoingVerification { - params := []pegomock.Param{repo, pull} - methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "GetModifiedFiles", params, verifier.timeout) - return &MockClient_GetModifiedFiles_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} -} - -type MockClient_GetModifiedFiles_OngoingVerification struct { - mock *MockClient - methodInvocations []pegomock.MethodInvocation -} - -func (c *MockClient_GetModifiedFiles_OngoingVerification) GetCapturedArguments() (models.Repo, models.PullRequest) { - repo, pull := c.GetAllCapturedArguments() - return repo[len(repo)-1], pull[len(pull)-1] -} - -func (c *MockClient_GetModifiedFiles_OngoingVerification) GetAllCapturedArguments() (_param0 []models.Repo, _param1 []models.PullRequest) { - params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations) - if len(params) > 0 { - _param0 = make([]models.Repo, len(c.methodInvocations)) - for u, param := range params[0] { - _param0[u] = param.(models.Repo) - } - _param1 = make([]models.PullRequest, len(c.methodInvocations)) - for u, param := range params[1] { - _param1[u] = param.(models.PullRequest) - } - } - return -} - -func (verifier *VerifierMockClient) CreateComment(repo models.Repo, pullNum int, comment string, command string) *MockClient_CreateComment_OngoingVerification { - params := []pegomock.Param{repo, pullNum, comment, command} +func (verifier *VerifierMockClient) CreateComment(_param0 models.Repo, _param1 int, _param2 string, _param3 string) *MockClient_CreateComment_OngoingVerification { + params := []pegomock.Param{_param0, _param1, _param2, _param3} methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "CreateComment", params, verifier.timeout) return &MockClient_CreateComment_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} } @@ -279,8 +248,8 @@ type MockClient_CreateComment_OngoingVerification struct { } func (c *MockClient_CreateComment_OngoingVerification) GetCapturedArguments() (models.Repo, int, string, string) { - repo, pullNum, comment, command := c.GetAllCapturedArguments() - return repo[len(repo)-1], pullNum[len(pullNum)-1], comment[len(comment)-1], command[len(command)-1] + _param0, _param1, _param2, _param3 := c.GetAllCapturedArguments() + return _param0[len(_param0)-1], _param1[len(_param1)-1], _param2[len(_param2)-1], _param3[len(_param3)-1] } func (c *MockClient_CreateComment_OngoingVerification) GetAllCapturedArguments() (_param0 []models.Repo, _param1 []int, _param2 []string, _param3 []string) { @@ -306,58 +275,50 @@ func (c *MockClient_CreateComment_OngoingVerification) GetAllCapturedArguments() return } -func (verifier *VerifierMockClient) HidePrevCommandComments(repo models.Repo, pullNum int, command string) *MockClient_HidePrevCommandComments_OngoingVerification { - params := []pegomock.Param{repo, pullNum, command} - methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "HidePrevCommandComments", params, verifier.timeout) - return &MockClient_HidePrevCommandComments_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} +func (verifier *VerifierMockClient) DownloadRepoConfigFile(_param0 models.PullRequest) *MockClient_DownloadRepoConfigFile_OngoingVerification { + params := []pegomock.Param{_param0} + methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "DownloadRepoConfigFile", params, verifier.timeout) + return &MockClient_DownloadRepoConfigFile_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} } -type MockClient_HidePrevCommandComments_OngoingVerification struct { +type MockClient_DownloadRepoConfigFile_OngoingVerification struct { mock *MockClient methodInvocations []pegomock.MethodInvocation } -func (c *MockClient_HidePrevCommandComments_OngoingVerification) GetCapturedArguments() (models.Repo, int, string) { - repo, pullNum, command := c.GetAllCapturedArguments() - return repo[len(repo)-1], pullNum[len(pullNum)-1], command[len(command)-1] +func (c *MockClient_DownloadRepoConfigFile_OngoingVerification) GetCapturedArguments() models.PullRequest { + _param0 := c.GetAllCapturedArguments() + return _param0[len(_param0)-1] } -func (c *MockClient_HidePrevCommandComments_OngoingVerification) GetAllCapturedArguments() (_param0 []models.Repo, _param1 []int, _param2 []string) { +func (c *MockClient_DownloadRepoConfigFile_OngoingVerification) GetAllCapturedArguments() (_param0 []models.PullRequest) { params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations) if len(params) > 0 { - _param0 = make([]models.Repo, len(c.methodInvocations)) + _param0 = make([]models.PullRequest, len(c.methodInvocations)) for u, param := range params[0] { - _param0[u] = param.(models.Repo) - } - _param1 = make([]int, len(c.methodInvocations)) - for u, param := range params[1] { - _param1[u] = param.(int) - } - _param2 = make([]string, len(c.methodInvocations)) - for u, param := range params[2] { - _param2[u] = param.(string) + _param0[u] = param.(models.PullRequest) } } return } -func (verifier *VerifierMockClient) PullIsApproved(repo models.Repo, pull models.PullRequest) *MockClient_PullIsApproved_OngoingVerification { - params := []pegomock.Param{repo, pull} - methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "PullIsApproved", params, verifier.timeout) - return &MockClient_PullIsApproved_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} +func (verifier *VerifierMockClient) GetModifiedFiles(_param0 models.Repo, _param1 models.PullRequest) *MockClient_GetModifiedFiles_OngoingVerification { + params := []pegomock.Param{_param0, _param1} + methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "GetModifiedFiles", params, verifier.timeout) + return &MockClient_GetModifiedFiles_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} } -type MockClient_PullIsApproved_OngoingVerification struct { +type MockClient_GetModifiedFiles_OngoingVerification struct { mock *MockClient methodInvocations []pegomock.MethodInvocation } -func (c *MockClient_PullIsApproved_OngoingVerification) GetCapturedArguments() (models.Repo, models.PullRequest) { - repo, pull := c.GetAllCapturedArguments() - return repo[len(repo)-1], pull[len(pull)-1] +func (c *MockClient_GetModifiedFiles_OngoingVerification) GetCapturedArguments() (models.Repo, models.PullRequest) { + _param0, _param1 := c.GetAllCapturedArguments() + return _param0[len(_param0)-1], _param1[len(_param1)-1] } -func (c *MockClient_PullIsApproved_OngoingVerification) GetAllCapturedArguments() (_param0 []models.Repo, _param1 []models.PullRequest) { +func (c *MockClient_GetModifiedFiles_OngoingVerification) GetAllCapturedArguments() (_param0 []models.Repo, _param1 []models.PullRequest) { params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations) if len(params) > 0 { _param0 = make([]models.Repo, len(c.methodInvocations)) @@ -372,86 +333,70 @@ func (c *MockClient_PullIsApproved_OngoingVerification) GetAllCapturedArguments( return } -func (verifier *VerifierMockClient) PullIsMergeable(repo models.Repo, pull models.PullRequest) *MockClient_PullIsMergeable_OngoingVerification { - params := []pegomock.Param{repo, pull} - methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "PullIsMergeable", params, verifier.timeout) - return &MockClient_PullIsMergeable_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} +func (verifier *VerifierMockClient) HidePrevCommandComments(_param0 models.Repo, _param1 int, _param2 string) *MockClient_HidePrevCommandComments_OngoingVerification { + params := []pegomock.Param{_param0, _param1, _param2} + methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "HidePrevCommandComments", params, verifier.timeout) + return &MockClient_HidePrevCommandComments_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} } -type MockClient_PullIsMergeable_OngoingVerification struct { +type MockClient_HidePrevCommandComments_OngoingVerification struct { mock *MockClient methodInvocations []pegomock.MethodInvocation } -func (c *MockClient_PullIsMergeable_OngoingVerification) GetCapturedArguments() (models.Repo, models.PullRequest) { - repo, pull := c.GetAllCapturedArguments() - return repo[len(repo)-1], pull[len(pull)-1] +func (c *MockClient_HidePrevCommandComments_OngoingVerification) GetCapturedArguments() (models.Repo, int, string) { + _param0, _param1, _param2 := c.GetAllCapturedArguments() + return _param0[len(_param0)-1], _param1[len(_param1)-1], _param2[len(_param2)-1] } -func (c *MockClient_PullIsMergeable_OngoingVerification) GetAllCapturedArguments() (_param0 []models.Repo, _param1 []models.PullRequest) { +func (c *MockClient_HidePrevCommandComments_OngoingVerification) GetAllCapturedArguments() (_param0 []models.Repo, _param1 []int, _param2 []string) { params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations) if len(params) > 0 { _param0 = make([]models.Repo, len(c.methodInvocations)) for u, param := range params[0] { _param0[u] = param.(models.Repo) } - _param1 = make([]models.PullRequest, len(c.methodInvocations)) + _param1 = make([]int, len(c.methodInvocations)) for u, param := range params[1] { - _param1[u] = param.(models.PullRequest) + _param1[u] = param.(int) + } + _param2 = make([]string, len(c.methodInvocations)) + for u, param := range params[2] { + _param2[u] = param.(string) } } return } -func (verifier *VerifierMockClient) UpdateStatus(repo models.Repo, pull models.PullRequest, state models.CommitStatus, src string, description string, url string) *MockClient_UpdateStatus_OngoingVerification { - params := []pegomock.Param{repo, pull, state, src, description, url} - methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "UpdateStatus", params, verifier.timeout) - return &MockClient_UpdateStatus_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} +func (verifier *VerifierMockClient) MarkdownPullLink(_param0 models.PullRequest) *MockClient_MarkdownPullLink_OngoingVerification { + params := []pegomock.Param{_param0} + methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "MarkdownPullLink", params, verifier.timeout) + return &MockClient_MarkdownPullLink_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} } -type MockClient_UpdateStatus_OngoingVerification struct { +type MockClient_MarkdownPullLink_OngoingVerification struct { mock *MockClient methodInvocations []pegomock.MethodInvocation } -func (c *MockClient_UpdateStatus_OngoingVerification) GetCapturedArguments() (models.Repo, models.PullRequest, models.CommitStatus, string, string, string) { - repo, pull, state, src, description, url := c.GetAllCapturedArguments() - return repo[len(repo)-1], pull[len(pull)-1], state[len(state)-1], src[len(src)-1], description[len(description)-1], url[len(url)-1] +func (c *MockClient_MarkdownPullLink_OngoingVerification) GetCapturedArguments() models.PullRequest { + _param0 := c.GetAllCapturedArguments() + return _param0[len(_param0)-1] } -func (c *MockClient_UpdateStatus_OngoingVerification) GetAllCapturedArguments() (_param0 []models.Repo, _param1 []models.PullRequest, _param2 []models.CommitStatus, _param3 []string, _param4 []string, _param5 []string) { +func (c *MockClient_MarkdownPullLink_OngoingVerification) GetAllCapturedArguments() (_param0 []models.PullRequest) { params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations) if len(params) > 0 { - _param0 = make([]models.Repo, len(c.methodInvocations)) + _param0 = make([]models.PullRequest, len(c.methodInvocations)) for u, param := range params[0] { - _param0[u] = param.(models.Repo) - } - _param1 = make([]models.PullRequest, len(c.methodInvocations)) - for u, param := range params[1] { - _param1[u] = param.(models.PullRequest) - } - _param2 = make([]models.CommitStatus, len(c.methodInvocations)) - for u, param := range params[2] { - _param2[u] = param.(models.CommitStatus) - } - _param3 = make([]string, len(c.methodInvocations)) - for u, param := range params[3] { - _param3[u] = param.(string) - } - _param4 = make([]string, len(c.methodInvocations)) - for u, param := range params[4] { - _param4[u] = param.(string) - } - _param5 = make([]string, len(c.methodInvocations)) - for u, param := range params[5] { - _param5[u] = param.(string) + _param0[u] = param.(models.PullRequest) } } return } -func (verifier *VerifierMockClient) MergePull(pull models.PullRequest, pullOptions models.PullRequestOptions) *MockClient_MergePull_OngoingVerification { - params := []pegomock.Param{pull, pullOptions} +func (verifier *VerifierMockClient) MergePull(_param0 models.PullRequest, _param1 models.PullRequestOptions) *MockClient_MergePull_OngoingVerification { + params := []pegomock.Param{_param0, _param1} methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "MergePull", params, verifier.timeout) return &MockClient_MergePull_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} } @@ -462,8 +407,8 @@ type MockClient_MergePull_OngoingVerification struct { } func (c *MockClient_MergePull_OngoingVerification) GetCapturedArguments() (models.PullRequest, models.PullRequestOptions) { - pull, pullOptions := c.GetAllCapturedArguments() - return pull[len(pull)-1], pullOptions[len(pullOptions)-1] + _param0, _param1 := c.GetAllCapturedArguments() + return _param0[len(_param0)-1], _param1[len(_param1)-1] } func (c *MockClient_MergePull_OngoingVerification) GetAllCapturedArguments() (_param0 []models.PullRequest, _param1 []models.PullRequestOptions) { @@ -481,62 +426,70 @@ func (c *MockClient_MergePull_OngoingVerification) GetAllCapturedArguments() (_p return } -func (verifier *VerifierMockClient) MarkdownPullLink(pull models.PullRequest) *MockClient_MarkdownPullLink_OngoingVerification { - params := []pegomock.Param{pull} - methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "MarkdownPullLink", params, verifier.timeout) - return &MockClient_MarkdownPullLink_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} +func (verifier *VerifierMockClient) PullIsApproved(_param0 models.Repo, _param1 models.PullRequest) *MockClient_PullIsApproved_OngoingVerification { + params := []pegomock.Param{_param0, _param1} + methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "PullIsApproved", params, verifier.timeout) + return &MockClient_PullIsApproved_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} } -type MockClient_MarkdownPullLink_OngoingVerification struct { +type MockClient_PullIsApproved_OngoingVerification struct { mock *MockClient methodInvocations []pegomock.MethodInvocation } -func (c *MockClient_MarkdownPullLink_OngoingVerification) GetCapturedArguments() models.PullRequest { - pull := c.GetAllCapturedArguments() - return pull[len(pull)-1] +func (c *MockClient_PullIsApproved_OngoingVerification) GetCapturedArguments() (models.Repo, models.PullRequest) { + _param0, _param1 := c.GetAllCapturedArguments() + return _param0[len(_param0)-1], _param1[len(_param1)-1] } -func (c *MockClient_MarkdownPullLink_OngoingVerification) GetAllCapturedArguments() (_param0 []models.PullRequest) { +func (c *MockClient_PullIsApproved_OngoingVerification) GetAllCapturedArguments() (_param0 []models.Repo, _param1 []models.PullRequest) { params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations) if len(params) > 0 { - _param0 = make([]models.PullRequest, len(c.methodInvocations)) + _param0 = make([]models.Repo, len(c.methodInvocations)) for u, param := range params[0] { - _param0[u] = param.(models.PullRequest) + _param0[u] = param.(models.Repo) + } + _param1 = make([]models.PullRequest, len(c.methodInvocations)) + for u, param := range params[1] { + _param1[u] = param.(models.PullRequest) } } return } -func (verifier *VerifierMockClient) DownloadRepoConfigFile(pull models.PullRequest) *MockClient_DownloadRepoConfigFile_OngoingVerification { - params := []pegomock.Param{pull} - methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "DownloadRepoConfigFile", params, verifier.timeout) - return &MockClient_DownloadRepoConfigFile_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} +func (verifier *VerifierMockClient) PullIsMergeable(_param0 models.Repo, _param1 models.PullRequest) *MockClient_PullIsMergeable_OngoingVerification { + params := []pegomock.Param{_param0, _param1} + methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "PullIsMergeable", params, verifier.timeout) + return &MockClient_PullIsMergeable_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} } -type MockClient_DownloadRepoConfigFile_OngoingVerification struct { +type MockClient_PullIsMergeable_OngoingVerification struct { mock *MockClient methodInvocations []pegomock.MethodInvocation } -func (c *MockClient_DownloadRepoConfigFile_OngoingVerification) GetCapturedArguments() models.PullRequest { - pull := c.GetAllCapturedArguments() - return pull[len(pull)-1] +func (c *MockClient_PullIsMergeable_OngoingVerification) GetCapturedArguments() (models.Repo, models.PullRequest) { + _param0, _param1 := c.GetAllCapturedArguments() + return _param0[len(_param0)-1], _param1[len(_param1)-1] } -func (c *MockClient_DownloadRepoConfigFile_OngoingVerification) GetAllCapturedArguments() (_param0 []models.PullRequest) { +func (c *MockClient_PullIsMergeable_OngoingVerification) GetAllCapturedArguments() (_param0 []models.Repo, _param1 []models.PullRequest) { params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations) if len(params) > 0 { - _param0 = make([]models.PullRequest, len(c.methodInvocations)) + _param0 = make([]models.Repo, len(c.methodInvocations)) for u, param := range params[0] { - _param0[u] = param.(models.PullRequest) + _param0[u] = param.(models.Repo) + } + _param1 = make([]models.PullRequest, len(c.methodInvocations)) + for u, param := range params[1] { + _param1[u] = param.(models.PullRequest) } } return } -func (verifier *VerifierMockClient) SupportsSingleFileDownload(repo models.Repo) *MockClient_SupportsSingleFileDownload_OngoingVerification { - params := []pegomock.Param{repo} +func (verifier *VerifierMockClient) SupportsSingleFileDownload(_param0 models.Repo) *MockClient_SupportsSingleFileDownload_OngoingVerification { + params := []pegomock.Param{_param0} methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "SupportsSingleFileDownload", params, verifier.timeout) return &MockClient_SupportsSingleFileDownload_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} } @@ -547,8 +500,8 @@ type MockClient_SupportsSingleFileDownload_OngoingVerification struct { } func (c *MockClient_SupportsSingleFileDownload_OngoingVerification) GetCapturedArguments() models.Repo { - repo := c.GetAllCapturedArguments() - return repo[len(repo)-1] + _param0 := c.GetAllCapturedArguments() + return _param0[len(_param0)-1] } func (c *MockClient_SupportsSingleFileDownload_OngoingVerification) GetAllCapturedArguments() (_param0 []models.Repo) { @@ -561,3 +514,50 @@ func (c *MockClient_SupportsSingleFileDownload_OngoingVerification) GetAllCaptur } return } + +func (verifier *VerifierMockClient) UpdateStatus(_param0 models.Repo, _param1 models.PullRequest, _param2 models.CommitStatus, _param3 string, _param4 string, _param5 string) *MockClient_UpdateStatus_OngoingVerification { + params := []pegomock.Param{_param0, _param1, _param2, _param3, _param4, _param5} + methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "UpdateStatus", params, verifier.timeout) + return &MockClient_UpdateStatus_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} +} + +type MockClient_UpdateStatus_OngoingVerification struct { + mock *MockClient + methodInvocations []pegomock.MethodInvocation +} + +func (c *MockClient_UpdateStatus_OngoingVerification) GetCapturedArguments() (models.Repo, models.PullRequest, models.CommitStatus, string, string, string) { + _param0, _param1, _param2, _param3, _param4, _param5 := c.GetAllCapturedArguments() + return _param0[len(_param0)-1], _param1[len(_param1)-1], _param2[len(_param2)-1], _param3[len(_param3)-1], _param4[len(_param4)-1], _param5[len(_param5)-1] +} + +func (c *MockClient_UpdateStatus_OngoingVerification) GetAllCapturedArguments() (_param0 []models.Repo, _param1 []models.PullRequest, _param2 []models.CommitStatus, _param3 []string, _param4 []string, _param5 []string) { + params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations) + if len(params) > 0 { + _param0 = make([]models.Repo, len(c.methodInvocations)) + for u, param := range params[0] { + _param0[u] = param.(models.Repo) + } + _param1 = make([]models.PullRequest, len(c.methodInvocations)) + for u, param := range params[1] { + _param1[u] = param.(models.PullRequest) + } + _param2 = make([]models.CommitStatus, len(c.methodInvocations)) + for u, param := range params[2] { + _param2[u] = param.(models.CommitStatus) + } + _param3 = make([]string, len(c.methodInvocations)) + for u, param := range params[3] { + _param3[u] = param.(string) + } + _param4 = make([]string, len(c.methodInvocations)) + for u, param := range params[4] { + _param4[u] = param.(string) + } + _param5 = make([]string, len(c.methodInvocations)) + for u, param := range params[5] { + _param5[u] = param.(string) + } + } + return +} diff --git a/server/events/vcs/not_configured_vcs_client.go b/server/events/vcs/not_configured_vcs_client.go index 3f8556765f..7780b1ef0d 100644 --- a/server/events/vcs/not_configured_vcs_client.go +++ b/server/events/vcs/not_configured_vcs_client.go @@ -35,8 +35,8 @@ func (a *NotConfiguredVCSClient) CreateComment(repo models.Repo, pullNum int, co func (a *NotConfiguredVCSClient) HidePrevCommandComments(repo models.Repo, pullNum int, command string) error { return nil } -func (a *NotConfiguredVCSClient) PullIsApproved(repo models.Repo, pull models.PullRequest) (bool, error) { - return false, a.err() +func (a *NotConfiguredVCSClient) PullIsApproved(repo models.Repo, pull models.PullRequest) (models.ApprovalStatus, error) { + return models.ApprovalStatus{}, a.err() } func (a *NotConfiguredVCSClient) PullIsMergeable(repo models.Repo, pull models.PullRequest) (bool, error) { return false, a.err() diff --git a/server/events/vcs/proxy.go b/server/events/vcs/proxy.go index c14563a467..5a9ed03132 100644 --- a/server/events/vcs/proxy.go +++ b/server/events/vcs/proxy.go @@ -64,7 +64,7 @@ func (d *ClientProxy) HidePrevCommandComments(repo models.Repo, pullNum int, com return d.clients[repo.VCSHost.Type].HidePrevCommandComments(repo, pullNum, command) } -func (d *ClientProxy) PullIsApproved(repo models.Repo, pull models.PullRequest) (bool, error) { +func (d *ClientProxy) PullIsApproved(repo models.Repo, pull models.PullRequest) (models.ApprovalStatus, error) { return d.clients[repo.VCSHost.Type].PullIsApproved(repo, pull) } From aa8cfb5d0d5e091195199423640ba62d49e5add5 Mon Sep 17 00:00:00 2001 From: Xiao Zhang <60601105+xiao-pp@users.noreply.github.com> Date: Fri, 24 Sep 2021 22:09:57 +0200 Subject: [PATCH 43/53] Fix title level (#1822) It generated confusing ToC/menu --- runatlantis.io/docs/apply-requirements.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runatlantis.io/docs/apply-requirements.md b/runatlantis.io/docs/apply-requirements.md index d1dc6787be..7e03df6b0e 100644 --- a/runatlantis.io/docs/apply-requirements.md +++ b/runatlantis.io/docs/apply-requirements.md @@ -168,7 +168,7 @@ You can set the `undiverged` requirement by: - dir: . apply_requirements: [undiverged] ``` -### Meaning +#### Meaning The `merge` checkout strategy creates a temporary merge commit and runs the `plan` on the Atlantis local version of the PR source and destination branch. The local destination branch can become out of date since changes to the destination branch are not fetched if there are no changes to the source branch. `undiverged` enforces that Atlantis local version of master is up to date From 9e791d89eed5a4207a0846251ccb117f7fd54c0e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Sep 2021 10:00:26 -0400 Subject: [PATCH 44/53] build(deps): bump github.com/xanzy/go-gitlab from 0.50.4 to 0.51.1 (#1831) Bumps [github.com/xanzy/go-gitlab](https://github.com/xanzy/go-gitlab) from 0.50.4 to 0.51.1. - [Release notes](https://github.com/xanzy/go-gitlab/releases) - [Changelog](https://github.com/xanzy/go-gitlab/blob/master/releases_test.go) - [Commits](https://github.com/xanzy/go-gitlab/compare/v0.50.4...v0.51.1) --- updated-dependencies: - dependency-name: github.com/xanzy/go-gitlab dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 581857c234..840b20bbeb 100644 --- a/go.mod +++ b/go.mod @@ -95,7 +95,7 @@ require ( github.com/ulikunitz/xz v0.5.8 // indirect github.com/urfave/cli v1.22.5 github.com/urfave/negroni v0.3.0 - github.com/xanzy/go-gitlab v0.50.4 + github.com/xanzy/go-gitlab v0.51.1 github.com/zclconf/go-cty v1.5.1 // indirect go.etcd.io/bbolt v1.3.6 go.opencensus.io v0.23.0 // indirect diff --git a/go.sum b/go.sum index a6b8ffb9e7..e476a2cdad 100644 --- a/go.sum +++ b/go.sum @@ -405,8 +405,8 @@ github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtX github.com/urfave/negroni v0.3.0 h1:PaXOb61mWeZJxc1Ji2xJjpVg9QfPo0rrB+lHyBxGNSU= github.com/urfave/negroni v0.3.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= -github.com/xanzy/go-gitlab v0.50.4 h1:DA0+D9eTBnZvrGBOQ66XV4ZV9gOFXKbbgm9L99EKCUs= -github.com/xanzy/go-gitlab v0.50.4/go.mod h1:Q+hQhV508bDPoBijv7YjK/Lvlb4PhVhJdKqXVQrUoAE= +github.com/xanzy/go-gitlab v0.51.1 h1:wWKLalwx4omxFoHh3PLs9zDgAD4GXDP/uoxwMRCSiWM= +github.com/xanzy/go-gitlab v0.51.1/go.mod h1:Q+hQhV508bDPoBijv7YjK/Lvlb4PhVhJdKqXVQrUoAE= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= From da7e04290b00472307661abda588dedb113a9258 Mon Sep 17 00:00:00 2001 From: wpbeckwith Date: Mon, 27 Sep 2021 11:26:37 -0500 Subject: [PATCH 45/53] Add support for deleting a branch on merge in BitBucket Server (#1792) * Add support for deleting a branch on merge in BitBucket Server * Add support for deleting a branch on merge in BitBucket Server * Making linter happy although the code would fall through and return err anyway. * Add client_test for deleting source branch * Added err check Co-authored-by: Wendell Beckwith --- server/events/vcs/bitbucketserver/client.go | 20 +++++++ .../events/vcs/bitbucketserver/client_test.go | 60 +++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/server/events/vcs/bitbucketserver/client.go b/server/events/vcs/bitbucketserver/client.go index fa23c3d07c..2a0e67e8f8 100644 --- a/server/events/vcs/bitbucketserver/client.go +++ b/server/events/vcs/bitbucketserver/client.go @@ -30,6 +30,11 @@ type Client struct { AtlantisURL string } +type DeleteSourceBranch struct { + Name string `json:"name"` + DryRun bool `json:"dryRun"` +} + // NewClient builds a bitbucket cloud client. Returns an error if the baseURL is // malformed. httpClient is the client to use to make the requests, username // and password are used as basic auth in the requests, baseURL is the API's @@ -267,6 +272,21 @@ func (b *Client) MergePull(pull models.PullRequest, pullOptions models.PullReque } path = fmt.Sprintf("%s/rest/api/1.0/projects/%s/repos/%s/pull-requests/%d/merge?version=%d", b.BaseURL, projectKey, pull.BaseRepo.Name, pull.Num, *pullResp.Version) _, err = b.makeRequest("POST", path, nil) + if err != nil { + return err + } + if pullOptions.DeleteSourceBranchOnMerge { + bodyBytes, err := json.Marshal(DeleteSourceBranch{Name: "refs/heads/" + pull.HeadBranch, DryRun: false}) + if err != nil { + return errors.Wrap(err, "json encoding") + } + + path = fmt.Sprintf("%s/rest/branch-utils/1.0/projects/%s/repos/%s/branches", b.BaseURL, projectKey, pull.BaseRepo.Name) + _, err = b.makeRequest("DELETE", path, bytes.NewBuffer(bodyBytes)) + if err != nil { + return err + } + } return err } diff --git a/server/events/vcs/bitbucketserver/client_test.go b/server/events/vcs/bitbucketserver/client_test.go index 016db6a344..2443e5f80e 100644 --- a/server/events/vcs/bitbucketserver/client_test.go +++ b/server/events/vcs/bitbucketserver/client_test.go @@ -1,6 +1,7 @@ package bitbucketserver_test import ( + "encoding/json" "fmt" "io/ioutil" "net/http" @@ -183,6 +184,65 @@ func TestClient_MergePull(t *testing.T) { Ok(t, err) } +// Test that we delete the source branch in our call to merge the pull +// request. +func TestClient_MergePullDeleteSourceBranch(t *testing.T) { + pullRequest, err := ioutil.ReadFile(filepath.Join("testdata", "pull-request.json")) + Ok(t, err) + testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.RequestURI { + // The first request should hit this URL. + case "/rest/api/1.0/projects/ow/repos/repo/pull-requests/1": + w.Write(pullRequest) // nolint: errcheck + return + case "/rest/api/1.0/projects/ow/repos/repo/pull-requests/1/merge?version=3": + Equals(t, "POST", r.Method) + w.Write(pullRequest) // nolint: errcheck + case "/rest/branch-utils/1.0/projects/ow/repos/repo/branches": + Equals(t, "DELETE", r.Method) + defer r.Body.Close() + b, err := ioutil.ReadAll(r.Body) + Ok(t, err) + var payload bitbucketserver.DeleteSourceBranch + err = json.Unmarshal(b, &payload) + Ok(t, err) + Equals(t, "refs/heads/foo", payload.Name) + w.WriteHeader(http.StatusNoContent) // nolint: errcheck + default: + t.Errorf("got unexpected request at %q", r.RequestURI) + http.Error(w, "not found", http.StatusNotFound) + return + } + })) + defer testServer.Close() + + client, err := bitbucketserver.NewClient(http.DefaultClient, "user", "pass", testServer.URL, "runatlantis.io") + Ok(t, err) + + err = client.MergePull(models.PullRequest{ + Num: 1, + HeadCommit: "", + URL: "", + HeadBranch: "foo", + BaseBranch: "", + Author: "", + State: 0, + BaseRepo: models.Repo{ + FullName: "owner/repo", + Owner: "owner", + Name: "repo", + SanitizedCloneURL: fmt.Sprintf("%s/scm/ow/repo.git", testServer.URL), + VCSHost: models.VCSHost{ + Type: models.BitbucketServer, + Hostname: "bitbucket.org", + }, + }, + }, models.PullRequestOptions{ + DeleteSourceBranchOnMerge: true, + }) + Ok(t, err) +} + func TestClient_MarkdownPullLink(t *testing.T) { client, err := bitbucketserver.NewClient(nil, "u", "p", "https://base-url", "atlantis-url") Ok(t, err) From c3d9e136ce57832c0c89e567bfea05f51f3b0d93 Mon Sep 17 00:00:00 2001 From: rui Date: Thu, 30 Sep 2021 23:33:24 -0400 Subject: [PATCH 46/53] deps: tf 1.0.8 (#1837) Signed-off-by: Rui Chen --- .circleci/config.yml | 2 +- Dockerfile | 2 +- testing/Dockerfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a70a09af7c..a1bb1a22c1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,7 +16,7 @@ jobs: # We do this instead of setting --default-tf-version because setting # that flag starts the download asynchronously so we'd have a race # condition. - TERRAFORM_VERSION: 1.0.7 + TERRAFORM_VERSION: 1.0.8 steps: - checkout - run: make build-service diff --git a/Dockerfile b/Dockerfile index d037ce48aa..09f3687fe0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM ghcr.io/runatlantis/atlantis-base:2021.08.31 # install terraform binaries -ENV DEFAULT_TERRAFORM_VERSION=1.0.7 +ENV DEFAULT_TERRAFORM_VERSION=1.0.8 # In the official Atlantis image we only have the latest of each Terraform version. RUN AVAILABLE_TERRAFORM_VERSIONS="0.8.8 0.9.11 0.10.8 0.11.15 0.12.31 0.13.7 0.14.11 0.15.5 ${DEFAULT_TERRAFORM_VERSION}" && \ diff --git a/testing/Dockerfile b/testing/Dockerfile index 235c5dd44d..e137e2fa93 100644 --- a/testing/Dockerfile +++ b/testing/Dockerfile @@ -1,7 +1,7 @@ FROM circleci/golang:1.17 # Install Terraform -ENV TERRAFORM_VERSION=1.0.7 +ENV TERRAFORM_VERSION=1.0.8 RUN curl -LOks https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip && \ sudo mkdir -p /usr/local/bin/tf/versions/${TERRAFORM_VERSION} && \ sudo unzip terraform_${TERRAFORM_VERSION}_linux_amd64.zip -d /usr/local/bin/tf/versions/${TERRAFORM_VERSION} && \ From fb46242ad597e5922bf573bc3efb68947082121b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Oct 2021 00:00:07 -0400 Subject: [PATCH 47/53] build(deps): bump github.com/spf13/viper from 1.8.1 to 1.9.0 (#1821) * build(deps): bump github.com/spf13/viper from 1.8.1 to 1.9.0 Bumps [github.com/spf13/viper](https://github.com/spf13/viper) from 1.8.1 to 1.9.0. - [Release notes](https://github.com/spf13/viper/releases) - [Commits](https://github.com/spf13/viper/compare/v1.8.1...v1.9.0) --- updated-dependencies: - dependency-name: github.com/spf13/viper dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * replace `golang.org/x/crypto/ssh/terminal` with `golang.org/x/term` * update go.mod Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Rui Chen --- go.mod | 45 ++++++------- go.sum | 165 ++++++++++++++++++++++++++++++--------------- testdrive/utils.go | 4 +- 3 files changed, 132 insertions(+), 82 deletions(-) diff --git a/go.mod b/go.mod index 840b20bbeb..8e434588e5 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.17 replace google.golang.org/grpc => google.golang.org/grpc v1.29.1 require ( - cloud.google.com/go v0.81.0 // indirect + cloud.google.com/go v0.93.3 // indirect cloud.google.com/go/storage v1.10.0 // indirect github.com/Laisky/graphql v1.0.5 github.com/Masterminds/goutils v1.1.1 // indirect @@ -23,21 +23,21 @@ require ( github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/docker/docker v0.0.0-20180620051407-e2593239d949 github.com/elazarl/go-bindata-assetfs v1.0.1 - github.com/fatih/color v1.7.0 // indirect + github.com/fatih/color v1.9.0 // indirect github.com/flynn-archive/go-shlex v0.0.0-20150515145356-3f9db97f8568 - github.com/fsnotify/fsnotify v1.4.10-0.20200417215612-7f4cf4dd2b52 // indirect + github.com/fsnotify/fsnotify v1.5.1 // indirect github.com/go-ozzo/ozzo-validation v0.0.0-20170913164239-85dcd8368eba github.com/go-playground/locales v0.12.1 // indirect github.com/go-playground/universal-translator v0.16.0 // indirect github.com/go-test/deep v1.0.7 github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect github.com/golang/protobuf v1.5.2 // indirect - github.com/google/go-cmp v0.5.5 // indirect + github.com/google/go-cmp v0.5.6 // indirect github.com/google/go-github/v29 v29.0.2 // indirect github.com/google/go-github/v31 v31.0.0 github.com/google/go-querystring v1.0.0 // indirect github.com/google/uuid v1.1.2-0.20200519141726-cb32006e483f // indirect - github.com/googleapis/gax-go/v2 v2.0.5 // indirect + github.com/googleapis/gax-go/v2 v2.1.0 // indirect github.com/gorilla/css v1.0.0 // indirect github.com/gorilla/mux v1.8.0 github.com/gorilla/websocket v1.4.2 // indirect @@ -53,13 +53,12 @@ require ( github.com/imdario/mergo v0.3.11 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/jmespath/go-jmespath v0.3.1-0.20200310193758-2437e8417af5 // indirect - github.com/jstemmer/go-junit-report v0.9.1 // indirect github.com/klauspost/compress v1.11.2 // indirect github.com/leodido/go-urn v1.2.0 // indirect github.com/lusis/slack-test v0.0.0-20190426140909-c40012f20018 // indirect github.com/magiconair/properties v1.8.5 // indirect - github.com/mattn/go-colorable v0.0.9 // indirect - github.com/mattn/go-isatty v0.0.4 // indirect + github.com/mattn/go-colorable v0.1.6 // indirect + github.com/mattn/go-isatty v0.0.12 // indirect github.com/mcdafydd/go-azuredevops v0.12.0 github.com/microcosm-cc/bluemonday v1.0.15 github.com/mitchellh/colorstring v0.0.0-20150917214807-8631ce90f286 @@ -67,13 +66,13 @@ require ( github.com/mitchellh/go-homedir v1.1.0 github.com/mitchellh/go-testing-interface v1.0.0 // indirect github.com/mitchellh/go-wordwrap v1.0.0 // indirect - github.com/mitchellh/mapstructure v1.4.1 // indirect + github.com/mitchellh/mapstructure v1.4.2 // indirect github.com/mitchellh/reflectwalk v1.0.0 // indirect github.com/mohae/deepcopy v0.0.0-20170603005431-491d3605edfb github.com/nlopes/slack v0.4.0 github.com/onsi/ginkgo v1.14.0 // indirect github.com/onsi/gomega v1.10.1 // indirect - github.com/pelletier/go-toml v1.9.3 // indirect + github.com/pelletier/go-toml v1.9.4 // indirect github.com/petergtz/pegomock v2.9.0+incompatible github.com/pkg/errors v0.9.1 github.com/pmezard/go-difflib v1.0.0 // indirect @@ -85,11 +84,11 @@ require ( github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect github.com/sirupsen/logrus v1.6.1-0.20200528085638-6699a89a232f // indirect github.com/spf13/afero v1.6.0 // indirect - github.com/spf13/cast v1.3.1 // indirect + github.com/spf13/cast v1.4.1 // indirect github.com/spf13/cobra v0.0.0-20170905172051-b78744579491 github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 - github.com/spf13/viper v1.8.1 + github.com/spf13/viper v1.9.0 github.com/stretchr/testify v1.7.0 github.com/subosito/gotenv v1.2.0 // indirect github.com/ulikunitz/xz v0.5.8 // indirect @@ -102,25 +101,23 @@ require ( go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.19.1 - golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 - golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect - golang.org/x/mod v0.4.2 // indirect golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect - golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602 // indirect - golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect + golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect + golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf // indirect + golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 golang.org/x/text v0.3.6 // indirect golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect - golang.org/x/tools v0.1.5 // indirect - golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect - google.golang.org/api v0.44.0 // indirect + google.golang.org/api v0.56.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect - google.golang.org/grpc v1.38.0 // indirect - google.golang.org/protobuf v1.26.0 // indirect + google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71 // indirect + google.golang.org/grpc v1.40.0 // indirect + google.golang.org/protobuf v1.27.1 // indirect gopkg.in/go-playground/assert.v1 v1.2.1 // indirect gopkg.in/go-playground/validator.v9 v9.31.0 - gopkg.in/ini.v1 v1.62.0 // indirect + gopkg.in/ini.v1 v1.63.2 // indirect gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect gotest.tools v2.2.0+incompatible // indirect ) + +require golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect diff --git a/go.sum b/go.sum index e476a2cdad..faf1a2d2d1 100644 --- a/go.sum +++ b/go.sum @@ -16,8 +16,13 @@ cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKP cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= -cloud.google.com/go v0.81.0 h1:at8Tk2zUz63cLPR0JPWm5vp77pEZmzxEQBEfRKn1VV8= cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= +cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= +cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= +cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= +cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= +cloud.google.com/go v0.93.3 h1:wPBktZFzYBcCZVARvwVKqH1uEj+aLXofJEtrb4oOsio= +cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= @@ -26,7 +31,7 @@ cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4g cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= +cloud.google.com/go/firestore v1.6.0/go.mod h1:afJwI0vaXwAG54kI7A//lP/lSPDkQORQuMkv56TxEPU= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= @@ -61,6 +66,7 @@ github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJE github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ= github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM= @@ -73,7 +79,6 @@ github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZx github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM= github.com/bradleyfalzon/ghinstallation v1.1.1 h1:pmBXkxgM1WeF8QYvDLT5kuQiHMcmf+X015GI0KM/E3I= github.com/bradleyfalzon/ghinstallation v1.1.1/go.mod h1:vyCmHTciHx/uuyN82Zc3rXN3X2KTK8nUTCrTMwAhcug= github.com/briandowns/spinner v0.0.0-20170614154858-48dbb65d7bd5 h1:osZyZB7J4kE1tKLeaUjV6+uZVBfS835T0I/RxmwWw1w= @@ -100,14 +105,15 @@ github.com/elazarl/go-bindata-assetfs v1.0.1 h1:m0kkaHRKEu7tUIUFVwhGGGYClXvyl4RE github.com/elazarl/go-bindata-assetfs v1.0.1/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s= +github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/flynn-archive/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BMXYYRWTLOJKlh+lOBt6nUQgXAfB7oVIQt5cNreqSLI= github.com/flynn-archive/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:rZfgFAXFS/z/lEd6LJmf9HVZ1LkgYiHx5pHhV5DR16M= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/fsnotify/fsnotify v1.4.10-0.20200417215612-7f4cf4dd2b52 h1:0NmERxogGTU8hgzOhRKNoKivtBZkDW29GeuJtK9e0sc= -github.com/fsnotify/fsnotify v1.4.10-0.20200417215612-7f4cf4dd2b52/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= +github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -137,6 +143,7 @@ github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -156,6 +163,7 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -168,8 +176,9 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-github/v29 v29.0.2 h1:opYN6Wc7DOz7Ku3Oh4l7prmkOMwEcQxpFtxdU8N8Pts= github.com/google/go-github/v29 v29.0.2/go.mod h1:CHKiKKPHJ0REzfwc14QMklvtHwCveD0PxlMjLlzAM5E= github.com/google/go-github/v31 v31.0.0 h1:JJUxlP9lFK+ziXKimTCprajMApV1ecWD4NB6CCb0plo= @@ -180,8 +189,9 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.1.0 h1:wCKgOCHuUEVfsaQLpPSJb7VdYCdTVZQAuOdYm1yc/60= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/martian/v3 v3.2.1 h1:d8MncMlErDFTwQGBK1xhv026j9kqhvw1Qv9IbWT1VLQ= +github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= @@ -193,15 +203,17 @@ github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2-0.20200519141726-cb32006e483f h1:qa1wFcvZzVLbFVPdsdTsWL6k5IP6BEmFmd9SeahRQ5s= github.com/google/uuid v1.1.2-0.20200519141726-cb32006e483f/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/googleapis/gax-go/v2 v2.1.0 h1:6DWmvNpomjL1+3liNSZbVns3zsYzzCjm6pRBO1tLeso= +github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY= github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= @@ -210,22 +222,24 @@ github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0U github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/graph-gophers/graphql-go v0.0.0-20200309224638-dae41bde9ef9/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= -github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= +github.com/hashicorp/consul/api v1.10.1/go.mod h1:XjsvQN+RJGWI2TWy1/kqaE16HrR2J/FWgkYjdZQsX9M= +github.com/hashicorp/consul/sdk v0.8.0/go.mod h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-getter v1.5.8 h1:qx5CZXxXz5YFpALPkbf/F1iZZoRE+f6T1i/AWw/Zkic= github.com/hashicorp/go-getter v1.5.8/go.mod h1:BrrV/1clo8cCYu6mxvboYg+KutTiFnXjMEgDD8+i7ZI= -github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxCsHI= github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= +github.com/hashicorp/go-hclog v0.12.0 h1:d4QkX8FRTYaKaCZBoXYY8zJX2BXjWxurN/GA2tkrmZM= +github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= github.com/hashicorp/go-retryablehttp v0.6.8 h1:92lWxgpa+fF3FozM4B3UZtHZMJX8T5XT+TFdCxsPyWs= github.com/hashicorp/go-retryablehttp v0.6.8/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= -github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= +github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= @@ -235,7 +249,6 @@ github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/b github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.3.0 h1:McDWVJIU/y+u1BRV06dPaLfLCaT7fUTJLp5r04x7iNw= github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w= @@ -245,9 +258,9 @@ github.com/hashicorp/hcl/v2 v2.0.0/go.mod h1:oVVDG71tEinNGYCxinCYadcmKU9bglqW9pV github.com/hashicorp/hcl/v2 v2.6.0 h1:3krZOfGY6SziUXa6H9PJU6TyohHn7I+ARYnhbeNBz+o= github.com/hashicorp/hcl/v2 v2.6.0/go.mod h1:bQTN5mpo+jewjJgh8jr0JUguIi7qPHUF6yIfAEN3jqY= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= -github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= -github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= +github.com/hashicorp/mdns v1.0.1/go.mod h1:4gW7WsVCke5TE7EPeYliwHlRUyBtfCwuFwuMg2DmyNY= +github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= +github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk= github.com/hashicorp/terraform-config-inspect v0.0.0-20200806211835-c481b8bfa41e h1:wIsEsIITggCC4FTO9PisDjy561UU7OPL6uTu7tnkHH8= github.com/hashicorp/terraform-config-inspect v0.0.0-20200806211835-c481b8bfa41e/go.mod h1:Z0Nnk4+3Cy89smEbrq+sl1bxc9198gIP4I7wcQF6Kqs= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= @@ -265,17 +278,15 @@ github.com/jmespath/go-jmespath v0.3.1-0.20200310193758-2437e8417af5 h1:1G6l+WCl github.com/jmespath/go-jmespath v0.3.1-0.20200310193758-2437e8417af5/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.11.2 h1:MiK62aErc3gIiVEtyzKfeOHgW7atJb5g/KNX5m3c2nQ= github.com/klauspost/compress v1.11.2/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= +github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= @@ -288,18 +299,25 @@ github.com/lusis/slack-test v0.0.0-20190426140909-c40012f20018 h1:MNApn+Z+fIT4NP github.com/lusis/slack-test v0.0.0-20190426140909-c40012f20018/go.mod h1:sFlOUpQL1YcjhFVXhg1CG8ZASEs/Mf1oVb6H75JL/zg= github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls= github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= -github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE= +github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= +github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= +github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mcdafydd/go-azuredevops v0.12.0 h1:CmG9uheFF6M3WnSykVNVLxR7zXrtg4p3pE2/lNDnPEE= github.com/mcdafydd/go-azuredevops v0.12.0/go.mod h1:B4UDyn7WEj1/97f45j3VnzEfkWKe05+/dCcAPdOET4A= github.com/microcosm-cc/bluemonday v1.0.15 h1:J4uN+qPng9rvkBZBoBb8YGR+ijuklIMpSOZZLjYpbeY= github.com/microcosm-cc/bluemonday v1.0.15/go.mod h1:ZLvAzeakRwrGnzQEvstVzVt3ZpqOF2+sdFr0Om+ce30= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= -github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= +github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= +github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= github.com/mitchellh/colorstring v0.0.0-20150917214807-8631ce90f286 h1:KHyL+3mQOF9sPfs26lsefckcFNDcIZtiACQiECzIUkw= github.com/mitchellh/colorstring v0.0.0-20150917214807-8631ce90f286/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw= github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ= @@ -312,12 +330,10 @@ github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eI github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= -github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= -github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= -github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/mapstructure v1.4.2 h1:6h7AQ0yhTcIsmFmnAwQls75jp2Gzs4iB8W7pjMO+rqo= +github.com/mitchellh/mapstructure v1.4.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -338,8 +354,8 @@ github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pelletier/go-toml v1.9.3 h1:zeC5b1GviRUyKYd6OJPvBU/mcVDVoL1OhT17FCt5dSQ= -github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= +github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhECwM= +github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/petergtz/pegomock v2.9.0+incompatible h1:BKfb5XfkJfehe5T+O1xD4Zm26Sb9dnRj7tHxLYwUPiI= github.com/petergtz/pegomock v2.9.0+incompatible/go.mod h1:nuBLWZpVyv/fLo56qTwt/AUau7jgouO1h7bEvZCq82o= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -349,6 +365,7 @@ github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/remeh/sizedwaitgroup v1.0.0 h1:VNGGFwNo/R5+MJBf6yrsr110p0m4/OX4S3DCy7Kyl5E= github.com/remeh/sizedwaitgroup v1.0.0/go.mod h1:3j2R4OIe/SeS6YDhICBy22RWjJC5eNCJ1V+9+NVNYlo= @@ -357,6 +374,7 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/sagikazarmark/crypt v0.1.0/go.mod h1:B/mN0msZuINBtQ1zZLEQcegFJJf9vnYIR88KRMEuODE= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= @@ -370,14 +388,11 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5I github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.6.1-0.20200528085638-6699a89a232f h1:qqqIhBDFUBrbMezIyJkKWIpf+E5CdObleGMjW1s19Hg= github.com/sirupsen/logrus v1.6.1-0.20200528085638-6699a89a232f/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= -github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY= github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= -github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA= +github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.0-20170905172051-b78744579491 h1:XOya2OGpG7Q4gS4MYHRoFSTlBGnZD40X+Kw2ikFQFXE= github.com/spf13/cobra v0.0.0-20170905172051-b78744579491/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= @@ -386,8 +401,8 @@ github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.8.1 h1:Kq1fyeebqsBfbjZj4EL7gj2IO0mMaiyjYUWcUsl2O44= -github.com/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns= +github.com/spf13/viper v1.9.0 h1:yR6EXjTp0y0cLN8OZg1CRZmOBdI88UcGkhgyJhu6nZk= +github.com/spf13/viper v1.9.0/go.mod h1:+i6ajR7OX2XaiBkrcZJFK21htRk7eDeLg7+O6bhUPP4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -444,11 +459,13 @@ golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200403201458-baeed622b8d8/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ= +golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -471,7 +488,6 @@ golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRu golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= @@ -483,13 +499,11 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -500,6 +514,7 @@ golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -523,6 +538,7 @@ golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210614182718-04defd469f4e h1:XpT3nA5TvE525Ne3hInMh6+GETgn27Zfm9dxsThnX2Q= golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -538,8 +554,11 @@ golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602 h1:0Ja1LBD+yisY6RWM/BH7TJVXWsSjs2VwBSmvSX4HdBc= -golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f h1:Qmd2pbz05z7z6lm0DrgQVVPuBm92jqujBKMHMOlOQEw= +golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -555,6 +574,7 @@ golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -564,14 +584,19 @@ golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -598,8 +623,16 @@ golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf h1:2ucpDCmfkl8Bd/FsLtiD653Wf96cW37s+iGx93zsu4k= +golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -619,7 +652,6 @@ golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3 golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= @@ -627,9 +659,9 @@ golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgw golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -663,8 +695,10 @@ golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA= +golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -692,8 +726,13 @@ google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34q google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= -google.golang.org/api v0.44.0 h1:URs6qR1lAxDsqWITsQXI4ZkGiYJ5dHtRNiCpfs2OeKA= -google.golang.org/api v0.44.0/go.mod h1:EBOGZqzyhtvMDoxwS97ctnh0zUmYY6CxqXsc1AvkYD8= +google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= +google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= +google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= +google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU= +google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= +google.golang.org/api v0.56.0 h1:08F9XVYTLOGeSQb3xI9C0gXMuQanhdGed0cWFhDozbI= +google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -742,10 +781,22 @@ google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= -google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c h1:wtujag7C+4D6KMoulW9YauvK2lgdvCMS260jsqqBXr0= +google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= +google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= +google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= +google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= +google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= +google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= +google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71 h1:z+ErRPu0+KS02Td3fOAgdX+lnPDh/VyaABEJPD4JRQs= +google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/grpc v1.29.1 h1:EC2SB8S04d2r73uptxphDSUG+kTKVgjRPF+N3xpxRB4= google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -757,11 +808,13 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= @@ -769,8 +822,8 @@ gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXa gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= gopkg.in/go-playground/validator.v9 v9.31.0 h1:bmXmP2RSNtFES+bn4uYuHT7iJFJv7Vj+an+ZQdDaD1M= gopkg.in/go-playground/validator.v9 v9.31.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= -gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU= -gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/ini.v1 v1.63.2 h1:tGK/CyBg7SMzb60vP1M03vNZ3VDu3wGQJwn7Sxi9r3c= +gopkg.in/ini.v1 v1.63.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/testdrive/utils.go b/testdrive/utils.go index 1452951a20..eb7a9c9fc4 100644 --- a/testdrive/utils.go +++ b/testdrive/utils.go @@ -31,7 +31,7 @@ import ( "time" "github.com/pkg/errors" - "golang.org/x/crypto/ssh/terminal" + "golang.org/x/term" ) const hashicorpReleasesURL = "https://releases.hashicorp.com" @@ -41,7 +41,7 @@ const ngrokAPIURL = "localhost:41414" // We hope this isn't used. const atlantisPort = 4141 func readPassword() (string, error) { - password, err := terminal.ReadPassword(int(syscall.Stdin)) // nolint: unconvert + password, err := term.ReadPassword(int(syscall.Stdin)) // nolint: unconvert return string(password), err } From bd66c1f99b73141488cb8b2ed83bc9a6a7cc90b7 Mon Sep 17 00:00:00 2001 From: Alexander Dupuy <75610395+dupuy26@users.noreply.github.com> Date: Fri, 1 Oct 2021 15:59:39 +0200 Subject: [PATCH 48/53] docs: document --auto-merge-disabled option (#1838) This flag was added in #1533 but was not documented. --- runatlantis.io/docs/automerging.md | 4 ++++ runatlantis.io/docs/using-atlantis.md | 1 + 2 files changed, 5 insertions(+) diff --git a/runatlantis.io/docs/automerging.md b/runatlantis.io/docs/automerging.md index 440e8b9b04..b0f4cdfe61 100644 --- a/runatlantis.io/docs/automerging.md +++ b/runatlantis.io/docs/automerging.md @@ -21,6 +21,10 @@ Automerging can be enabled either by: to be configured under the `projects` key. ::: +## How to Disable +If automerge is enabled, you can disable it for a single `atlantis apply` +command with the `--auto-merge-disabled` option. + ## All Plans Must Succeed When automerge is enabled, **all plans** in a pull request **must succeed** before **any** plans can be applied. diff --git a/runatlantis.io/docs/using-atlantis.md b/runatlantis.io/docs/using-atlantis.md index 24a0a29352..4695831e81 100644 --- a/runatlantis.io/docs/using-atlantis.md +++ b/runatlantis.io/docs/using-atlantis.md @@ -86,6 +86,7 @@ atlantis apply -w staging * `-d directory` Apply the plan for this directory, relative to root of repo. Use `.` for root. * `-p project` Apply the plan for this project. Refers to the name of the project configured in the repo's [`atlantis.yaml` file](repo-level-atlantis-yaml.html). Cannot be used at same time as `-d` or `-w`. * `-w workspace` Apply the plan for this [Terraform workspace](https://www.terraform.io/docs/state/workspaces.html). If not using Terraform workspaces you can ignore this. +* `--auto-merge-disabled` Disable [automerge](automerging.html) for this apply command. * `--verbose` Append Atlantis log to comment. ### Additional Terraform flags From b55f38696263ae8402ed7cdf08d1995cf6674b8b Mon Sep 17 00:00:00 2001 From: rui Date: Sun, 3 Oct 2021 13:28:11 -0400 Subject: [PATCH 49/53] testdrive: update terraformVersion (#1839) Signed-off-by: Rui Chen --- testdrive/utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testdrive/utils.go b/testdrive/utils.go index eb7a9c9fc4..2edafec1bb 100644 --- a/testdrive/utils.go +++ b/testdrive/utils.go @@ -35,7 +35,7 @@ import ( ) const hashicorpReleasesURL = "https://releases.hashicorp.com" -const terraformVersion = "0.10.8" +const terraformVersion = "1.0.8" const ngrokDownloadURL = "https://bin.equinox.io/c/4VmDzA7iaHb" const ngrokAPIURL = "localhost:41414" // We hope this isn't used. const atlantisPort = 4141 From 875e2adc40a0488518b12944baec6c082b78d806 Mon Sep 17 00:00:00 2001 From: "Nicholas (Nick) Meyer" Date: Mon, 4 Oct 2021 09:59:53 -0700 Subject: [PATCH 50/53] Improve github pull request call retries (#1810) * Improve github pull request call retries Retry with fixed 1 second backoff up to 3 retries was added by #1131 to address #1019, but the issue continued to show up (#1453). Increase max attempts to 5 and use exponential backoff for a maximum total retry time of (2^n - n - 1) seconds, which is roughly 30 seconds for current max attempts n = 5. Also move the sleep to the top of the loop so that we never sleep without sending the request again on the last iteration. * Fix style with gofmt -s --- server/events/vcs/github_client.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/server/events/vcs/github_client.go b/server/events/vcs/github_client.go index f55a9e7882..117a2d3fcb 100644 --- a/server/events/vcs/github_client.go +++ b/server/events/vcs/github_client.go @@ -292,10 +292,14 @@ func (g *GithubClient) GetPullRequest(repo models.Repo, num int) (*github.PullRe // GitHub has started to return 404's here (#1019) even after they send the webhook. // They've got some eventual consistency issues going on so we're just going - // to retry up to 3 times with a 1s sleep. - numRetries := 3 - retryDelay := 1 * time.Second - for i := 0; i < numRetries; i++ { + // to attempt up to 5 times with exponential backoff. + maxAttempts := 5 + attemptDelay := 0 * time.Second + for i := 0; i < maxAttempts; i++ { + // First don't sleep, then sleep 1, 3, 7, etc. + time.Sleep(attemptDelay) + attemptDelay = 2*attemptDelay + 1*time.Second + pull, _, err = g.client.PullRequests.Get(g.ctx, repo.Owner, repo.Name, num) if err == nil { return pull, nil @@ -304,7 +308,6 @@ func (g *GithubClient) GetPullRequest(repo models.Repo, num int) (*github.PullRe if !ok || ghErr.Response.StatusCode != 404 { return pull, err } - time.Sleep(retryDelay) } return pull, err } From 4d4f1340db9bec58f32a609e5ff801e7cb4262a4 Mon Sep 17 00:00:00 2001 From: rui Date: Tue, 5 Oct 2021 21:18:35 -0400 Subject: [PATCH 51/53] release: 0.17.4 (#1841) --- CHANGELOG.md | 33 +++++++++++++++++++++++++++++++++ kustomize/bundle.yaml | 2 +- main.go | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c6ca34ecfa..7af0b016f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,36 @@ +# v0.17.4 + +## What's Changed + +* build(deps): bump tar from 4.4.15 to 4.4.19 by @dependabot in https://github.com/runatlantis/atlantis/pull/1783 +* build: tf 1.0.6 by @chenrui333 in https://github.com/runatlantis/atlantis/pull/1786 +* Bump testing image conftest version to 0.27 by @nishkrishnan in https://github.com/runatlantis/atlantis/pull/1787 +* Actually bump testing image conftest version to 0.27 by @nishkrishnan in https://github.com/runatlantis/atlantis/pull/1788 +* build: fix testing-env img process by @chenrui333 in https://github.com/runatlantis/atlantis/pull/1789 +* e2e: update dockerfile by @chenrui333 in https://github.com/runatlantis/atlantis/pull/1790 +* build(deps): bump runatlantis/atlantis-base from 2021.06.22 to 2021.08.31 by @dependabot in https://github.com/runatlantis/atlantis/pull/1794 +* build(deps): bump github.com/xanzy/go-gitlab from 0.50.3 to 0.50.4 by @dependabot in https://github.com/runatlantis/atlantis/pull/1795 +* fix a log error typo by @danpilch in https://github.com/runatlantis/atlantis/pull/1796 +* Set ParallelPolicyCheckEnabled to the same value as ParallelPlanEnabled by @msarvar in https://github.com/runatlantis/atlantis/pull/1802 +* docs: Add missing --silence-vcs-status-no-plans flag by @franklad in https://github.com/runatlantis/atlantis/pull/1803 +* build(lint): use revive instead of golint by @minamijoyo in https://github.com/runatlantis/atlantis/pull/1801 +* build(deps): bump github.com/hashicorp/go-getter from 1.5.7 to 1.5.8 by @dependabot in https://github.com/runatlantis/atlantis/pull/1807 +* build(deps): bump go.uber.org/zap from 1.19.0 to 1.19.1 by @dependabot in https://github.com/runatlantis/atlantis/pull/1808 +* docs: add missing the `branch` key in the reference for server side repo config by @minamijoyo in https://github.com/runatlantis/atlantis/pull/1784 +* build: tf 1.0.7 by @chenrui333 in https://github.com/runatlantis/atlantis/pull/1811 +* deps: conftest 0.28.0 by @chenrui333 in https://github.com/runatlantis/atlantis/pull/1819 +* deps: conftest 0.28.1 by @chenrui333 in https://github.com/runatlantis/atlantis/pull/1826 +* build(deps): bump prismjs from 1.24.0 to 1.25.0 by @dependabot in https://github.com/runatlantis/atlantis/pull/1823 +* Updating client interface and adding ApprovalStatus model by @Aayyush in https://github.com/runatlantis/atlantis/pull/1827 +* Fix title level by @xiao-pp in https://github.com/runatlantis/atlantis/pull/1822 +* build(deps): bump github.com/xanzy/go-gitlab from 0.50.4 to 0.51.1 by @dependabot in https://github.com/runatlantis/atlantis/pull/1831 +* Add support for deleting a branch on merge in BitBucket Server by @wpbeckwith in https://github.com/runatlantis/atlantis/pull/1792 +* deps: tf 1.0.8 by @chenrui333 in https://github.com/runatlantis/atlantis/pull/1837 +* build(deps): bump github.com/spf13/viper from 1.8.1 to 1.9.0 by @dependabot in https://github.com/runatlantis/atlantis/pull/1821 +* Document --auto-merge-disabled option by @dupuy26 in https://github.com/runatlantis/atlantis/pull/1838 +* testdrive: update terraformVersion by @chenrui333 in https://github.com/runatlantis/atlantis/pull/1839 +* Improve github pull request call retries by @aristocrates in https://github.com/runatlantis/atlantis/pull/1810 + # v0.17.3 Feature release with a number of improvements related to Gitlab support, a new command, better formatting etc. Some broken features have been fixed in along with some regressions. diff --git a/kustomize/bundle.yaml b/kustomize/bundle.yaml index 3c2f4e56e3..d99004eb7c 100644 --- a/kustomize/bundle.yaml +++ b/kustomize/bundle.yaml @@ -22,7 +22,7 @@ spec: fsGroup: 1000 # Atlantis group (1000) read/write access to volumes. containers: - name: atlantis - image: ghcr.io/runatlantis/atlantis:v0.17.3 + image: ghcr.io/runatlantis/atlantis:v0.17.4 env: - name: ATLANTIS_DATA_DIR value: /atlantis diff --git a/main.go b/main.go index bbde2aa491..041d9c21d9 100644 --- a/main.go +++ b/main.go @@ -22,7 +22,7 @@ import ( "github.com/spf13/viper" ) -const atlantisVersion = "0.17.3" +const atlantisVersion = "0.17.4" func main() { v := viper.New() From 38cf7b014137637c065513b2077eca0c8ef43541 Mon Sep 17 00:00:00 2001 From: Eng Zer Jun Date: Thu, 7 Oct 2021 12:37:42 +0800 Subject: [PATCH 52/53] refactor: move from io/ioutil to io and os package (#1843) The io/ioutil package has been deprecated as of Go 1.16, see https://golang.org/doc/go1.16#ioutil. This commit replaces the existing io/ioutil functions with their new definitions in io and os packages. Signed-off-by: Eng Zer Jun --- cmd/server_test.go | 5 ++- e2e/e2e.go | 3 +- .../events/azuredevops_request_validator.go | 4 +-- .../controllers/events/events_controller.go | 6 ++-- .../events/events_controller_e2e_test.go | 17 +++++----- .../events/events_controller_test.go | 21 ++++++------ .../events/github_request_validator.go | 4 +-- .../events/gitlab_request_parser_validator.go | 4 +-- server/controllers/status_controller_test.go | 8 ++--- server/core/db/boltdb_test.go | 3 +- server/core/runtime/apply_step_runner.go | 5 ++- server/core/runtime/apply_step_runner_test.go | 13 ++++--- server/core/runtime/init_step_runner_test.go | 8 ++--- server/core/runtime/plan_step_runner.go | 3 +- server/core/runtime/plan_step_runner_test.go | 5 ++- .../runtime/plan_type_step_runner_delegate.go | 4 +-- .../plan_type_step_runner_delegate_test.go | 10 +++--- server/core/runtime/show_step_runner.go | 3 +- server/core/runtime/show_step_runner_test.go | 8 ++--- server/core/terraform/terraform_client.go | 5 ++- .../terraform_client_internal_test.go | 9 +++-- .../core/terraform/terraform_client_test.go | 13 ++++--- server/events/comment_parser.go | 10 +++--- server/events/event_parser_test.go | 34 +++++++++---------- server/events/git_cred_writer.go | 13 ++++--- server/events/git_cred_writer_test.go | 22 ++++++------ server/events/pending_plan_finder.go | 3 +- .../project_command_builder_internal_test.go | 14 ++++---- server/events/project_command_builder_test.go | 10 +++--- server/events/project_finder_test.go | 7 ++-- server/events/vcs/azuredevops_client_test.go | 13 +++---- server/events/vcs/bitbucketcloud/client.go | 5 ++- .../events/vcs/bitbucketcloud/client_test.go | 4 +-- server/events/vcs/bitbucketserver/client.go | 5 ++- .../events/vcs/bitbucketserver/client_test.go | 9 ++--- server/events/vcs/github_client_test.go | 21 ++++++------ server/events/vcs/gitlab_client_test.go | 4 +-- server/events/yaml/parser_validator.go | 5 ++- server/events/yaml/parser_validator_test.go | 15 ++++---- server/events/yaml/valid/global_cfg_test.go | 6 ++-- server/recovery/recovery.go | 4 +-- server/server.go | 3 +- server/server_test.go | 9 ++--- testdrive/testdrive.go | 7 ++-- testdrive/utils.go | 3 +- testing/http.go | 4 +-- testing/temp_files.go | 5 ++- 47 files changed, 189 insertions(+), 207 deletions(-) diff --git a/cmd/server_test.go b/cmd/server_test.go index 388c79541c..95d82aa31e 100644 --- a/cmd/server_test.go +++ b/cmd/server_test.go @@ -15,7 +15,6 @@ package cmd import ( "fmt" - "io/ioutil" "os" "path/filepath" "reflect" @@ -837,12 +836,12 @@ func setupWithDefaults(flags map[string]interface{}, t *testing.T) *cobra.Comman } func tempFile(t *testing.T, contents string) string { - f, err := ioutil.TempFile("", "") + f, err := os.CreateTemp("", "") Ok(t, err) newName := f.Name() + ".yaml" err = os.Rename(f.Name(), newName) Ok(t, err) - ioutil.WriteFile(newName, []byte(contents), 0600) // nolint: errcheck + os.WriteFile(newName, []byte(contents), 0600) // nolint: errcheck return newName } diff --git a/e2e/e2e.go b/e2e/e2e.go index ee44a2a73a..5addf721e0 100644 --- a/e2e/e2e.go +++ b/e2e/e2e.go @@ -15,7 +15,6 @@ package main import ( "fmt" - "io/ioutil" "log" "os" "os/exec" @@ -78,7 +77,7 @@ func (t *E2ETester) Start() (*E2EResult, error) { randomData := []byte(testFileData) filePath := fmt.Sprintf("%s/%s/%s", cloneDir, t.projectType.Name, testFileName) log.Printf("creating file to commit %q", filePath) - err := ioutil.WriteFile(filePath, randomData, 0644) + err := os.WriteFile(filePath, randomData, 0644) if err != nil { return e2eResult, fmt.Errorf("couldn't write file %s: %v", filePath, err) } diff --git a/server/controllers/events/azuredevops_request_validator.go b/server/controllers/events/azuredevops_request_validator.go index 0b6e77e4f9..e0786d8eba 100644 --- a/server/controllers/events/azuredevops_request_validator.go +++ b/server/controllers/events/azuredevops_request_validator.go @@ -2,7 +2,7 @@ package events import ( "fmt" - "io/ioutil" + "io" "net/http" "github.com/mcdafydd/go-azuredevops/azuredevops" @@ -47,7 +47,7 @@ func (d *DefaultAzureDevopsRequestValidator) validateWithBasicAuth(r *http.Reque func (d *DefaultAzureDevopsRequestValidator) validateWithoutBasicAuth(r *http.Request) ([]byte, error) { ct := r.Header.Get("Content-Type") if ct == "application/json" || ct == "application/json; charset=utf-8" { - payload, err := ioutil.ReadAll(r.Body) + payload, err := io.ReadAll(r.Body) if err != nil { return nil, fmt.Errorf("could not read body: %s", err) } diff --git a/server/controllers/events/events_controller.go b/server/controllers/events/events_controller.go index 7164d10da7..c94f2d648c 100644 --- a/server/controllers/events/events_controller.go +++ b/server/controllers/events/events_controller.go @@ -15,7 +15,7 @@ package events import ( "fmt" - "io/ioutil" + "io" "net/http" "strings" @@ -163,7 +163,7 @@ func (e *VCSEventsController) handleBitbucketCloudPost(w http.ResponseWriter, r eventType := r.Header.Get(bitbucketEventTypeHeader) reqID := r.Header.Get(bitbucketCloudRequestIDHeader) defer r.Body.Close() // nolint: errcheck - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) if err != nil { e.respond(w, logging.Error, http.StatusBadRequest, "Unable to read body: %s %s=%s", err, bitbucketCloudRequestIDHeader, reqID) return @@ -187,7 +187,7 @@ func (e *VCSEventsController) handleBitbucketServerPost(w http.ResponseWriter, r reqID := r.Header.Get(bitbucketServerRequestIDHeader) sig := r.Header.Get(bitbucketServerSignatureHeader) defer r.Body.Close() // nolint: errcheck - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) if err != nil { e.respond(w, logging.Error, http.StatusBadRequest, "Unable to read body: %s %s=%s", err, bitbucketServerRequestIDHeader, reqID) return diff --git a/server/controllers/events/events_controller_e2e_test.go b/server/controllers/events/events_controller_e2e_test.go index 06db9b5045..6db49d49a0 100644 --- a/server/controllers/events/events_controller_e2e_test.go +++ b/server/controllers/events/events_controller_e2e_test.go @@ -3,7 +3,6 @@ package events_test import ( "bytes" "fmt" - "io/ioutil" "net/http" "net/http/httptest" "os" @@ -527,7 +526,7 @@ func TestSimlpleWorkflow_terraformLockFile(t *testing.T) { oldLockFilePath, err := filepath.Abs(filepath.Join("testfixtures", "null_provider_lockfile_old_version")) Ok(t, err) - oldLockFileContent, err := ioutil.ReadFile(oldLockFilePath) + oldLockFileContent, err := os.ReadFile(oldLockFilePath) Ok(t, err) if c.LockFileTracked { @@ -549,7 +548,7 @@ func TestSimlpleWorkflow_terraformLockFile(t *testing.T) { ResponseContains(t, w, 200, "Processing...") // check lock file content - actualLockFileContent, err := ioutil.ReadFile(fmt.Sprintf("%s/repos/runatlantis/atlantis-tests/2/default/.terraform.lock.hcl", atlantisWorkspace.DataDir)) + actualLockFileContent, err := os.ReadFile(fmt.Sprintf("%s/repos/runatlantis/atlantis-tests/2/default/.terraform.lock.hcl", atlantisWorkspace.DataDir)) Ok(t, err) if c.LockFileTracked { if string(oldLockFileContent) != string(actualLockFileContent) { @@ -578,7 +577,7 @@ func TestSimlpleWorkflow_terraformLockFile(t *testing.T) { } // check lock file content - actualLockFileContent, err = ioutil.ReadFile(fmt.Sprintf("%s/repos/runatlantis/atlantis-tests/2/default/.terraform.lock.hcl", atlantisWorkspace.DataDir)) + actualLockFileContent, err = os.ReadFile(fmt.Sprintf("%s/repos/runatlantis/atlantis-tests/2/default/.terraform.lock.hcl", atlantisWorkspace.DataDir)) Ok(t, err) if c.LockFileTracked { if string(oldLockFileContent) != string(actualLockFileContent) { @@ -1086,7 +1085,7 @@ func (w *mockWebhookSender) Send(log logging.SimpleLogging, result webhooks.Appl } func GitHubCommentEvent(t *testing.T, comment string) *http.Request { - requestJSON, err := ioutil.ReadFile(filepath.Join("testfixtures", "githubIssueCommentEvent.json")) + requestJSON, err := os.ReadFile(filepath.Join("testfixtures", "githubIssueCommentEvent.json")) Ok(t, err) requestJSON = []byte(strings.Replace(string(requestJSON), "###comment body###", comment, 1)) req, err := http.NewRequest("POST", "/events", bytes.NewBuffer(requestJSON)) @@ -1097,7 +1096,7 @@ func GitHubCommentEvent(t *testing.T, comment string) *http.Request { } func GitHubPullRequestOpenedEvent(t *testing.T, headSHA string) *http.Request { - requestJSON, err := ioutil.ReadFile(filepath.Join("testfixtures", "githubPullRequestOpenedEvent.json")) + requestJSON, err := os.ReadFile(filepath.Join("testfixtures", "githubPullRequestOpenedEvent.json")) Ok(t, err) // Replace sha with expected sha. requestJSONStr := strings.Replace(string(requestJSON), "c31fd9ea6f557ad2ea659944c3844a059b83bc5d", headSHA, -1) @@ -1109,7 +1108,7 @@ func GitHubPullRequestOpenedEvent(t *testing.T, headSHA string) *http.Request { } func GitHubPullRequestClosedEvent(t *testing.T) *http.Request { - requestJSON, err := ioutil.ReadFile(filepath.Join("testfixtures", "githubPullRequestClosedEvent.json")) + requestJSON, err := os.ReadFile(filepath.Join("testfixtures", "githubPullRequestClosedEvent.json")) Ok(t, err) req, err := http.NewRequest("POST", "/events", bytes.NewBuffer(requestJSON)) Ok(t, err) @@ -1219,7 +1218,7 @@ func assertCommentEquals(t *testing.T, expReplies []string, act string, repoDir } for _, expFile := range expReplies { - exp, err := ioutil.ReadFile(filepath.Join(absRepoPath(t, repoDir), expFile)) + exp, err := os.ReadFile(filepath.Join(absRepoPath(t, repoDir), expFile)) Ok(t, err) expStr := string(exp) // My editor adds a newline to all the files, so if the actual comment @@ -1237,7 +1236,7 @@ func assertCommentEquals(t *testing.T, expReplies []string, act string, repoDir t.FailNow() } else { actFile := filepath.Join(absRepoPath(t, repoDir), expFile+".act") - err := ioutil.WriteFile(actFile, []byte(act), 0600) + err := os.WriteFile(actFile, []byte(act), 0600) Ok(t, err) cwd, err := os.Getwd() Ok(t, err) diff --git a/server/controllers/events/events_controller_test.go b/server/controllers/events/events_controller_test.go index 2ff5b1e4a5..dff2ffbb8b 100644 --- a/server/controllers/events/events_controller_test.go +++ b/server/controllers/events/events_controller_test.go @@ -17,9 +17,10 @@ import ( "bytes" "errors" "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" + "os" "path/filepath" "reflect" "strings" @@ -201,7 +202,7 @@ func TestPost_GitlabCommentNotAllowlisted(t *testing.T) { RepoAllowlistChecker: &events.RepoAllowlistChecker{}, VCSClient: vcsClient, } - requestJSON, err := ioutil.ReadFile(filepath.Join("testfixtures", "gitlabMergeCommentEvent_notAllowlisted.json")) + requestJSON, err := os.ReadFile(filepath.Join("testfixtures", "gitlabMergeCommentEvent_notAllowlisted.json")) Ok(t, err) req, _ := http.NewRequest("GET", "", bytes.NewBuffer(requestJSON)) req.Header.Set(gitlabHeader, "Note Hook") @@ -209,7 +210,7 @@ func TestPost_GitlabCommentNotAllowlisted(t *testing.T) { e.Post(w, req) Equals(t, http.StatusForbidden, w.Result().StatusCode) - body, _ := ioutil.ReadAll(w.Result().Body) + body, _ := io.ReadAll(w.Result().Body) exp := "Repo not allowlisted" Assert(t, strings.Contains(string(body), exp), "exp %q to be contained in %q", exp, string(body)) expRepo, _ := models.NewRepo(models.Gitlab, "gitlabhq/gitlab-test", "https://example.com/gitlabhq/gitlab-test.git", "", "") @@ -230,7 +231,7 @@ func TestPost_GitlabCommentNotAllowlistedWithSilenceErrors(t *testing.T) { VCSClient: vcsClient, SilenceAllowlistErrors: true, } - requestJSON, err := ioutil.ReadFile(filepath.Join("testfixtures", "gitlabMergeCommentEvent_notAllowlisted.json")) + requestJSON, err := os.ReadFile(filepath.Join("testfixtures", "gitlabMergeCommentEvent_notAllowlisted.json")) Ok(t, err) req, _ := http.NewRequest("GET", "", bytes.NewBuffer(requestJSON)) req.Header.Set(gitlabHeader, "Note Hook") @@ -238,7 +239,7 @@ func TestPost_GitlabCommentNotAllowlistedWithSilenceErrors(t *testing.T) { e.Post(w, req) Equals(t, http.StatusForbidden, w.Result().StatusCode) - body, _ := ioutil.ReadAll(w.Result().Body) + body, _ := io.ReadAll(w.Result().Body) exp := "Repo not allowlisted" Assert(t, strings.Contains(string(body), exp), "exp %q to be contained in %q", exp, string(body)) vcsClient.VerifyWasCalled(Never()).CreateComment(matchers.AnyModelsRepo(), AnyInt(), AnyString(), AnyString()) @@ -258,7 +259,7 @@ func TestPost_GithubCommentNotAllowlisted(t *testing.T) { RepoAllowlistChecker: &events.RepoAllowlistChecker{}, VCSClient: vcsClient, } - requestJSON, err := ioutil.ReadFile(filepath.Join("testfixtures", "githubIssueCommentEvent_notAllowlisted.json")) + requestJSON, err := os.ReadFile(filepath.Join("testfixtures", "githubIssueCommentEvent_notAllowlisted.json")) Ok(t, err) req, _ := http.NewRequest("GET", "", bytes.NewBuffer(requestJSON)) req.Header.Set("Content-Type", "application/json") @@ -267,7 +268,7 @@ func TestPost_GithubCommentNotAllowlisted(t *testing.T) { e.Post(w, req) Equals(t, http.StatusForbidden, w.Result().StatusCode) - body, _ := ioutil.ReadAll(w.Result().Body) + body, _ := io.ReadAll(w.Result().Body) exp := "Repo not allowlisted" Assert(t, strings.Contains(string(body), exp), "exp %q to be contained in %q", exp, string(body)) expRepo, _ := models.NewRepo(models.Github, "baxterthehacker/public-repo", "https://github.com/baxterthehacker/public-repo.git", "", "") @@ -288,7 +289,7 @@ func TestPost_GithubCommentNotAllowlistedWithSilenceErrors(t *testing.T) { VCSClient: vcsClient, SilenceAllowlistErrors: true, } - requestJSON, err := ioutil.ReadFile(filepath.Join("testfixtures", "githubIssueCommentEvent_notAllowlisted.json")) + requestJSON, err := os.ReadFile(filepath.Join("testfixtures", "githubIssueCommentEvent_notAllowlisted.json")) Ok(t, err) req, _ := http.NewRequest("GET", "", bytes.NewBuffer(requestJSON)) req.Header.Set("Content-Type", "application/json") @@ -297,7 +298,7 @@ func TestPost_GithubCommentNotAllowlistedWithSilenceErrors(t *testing.T) { e.Post(w, req) Equals(t, http.StatusForbidden, w.Result().StatusCode) - body, _ := ioutil.ReadAll(w.Result().Body) + body, _ := io.ReadAll(w.Result().Body) exp := "Repo not allowlisted" Assert(t, strings.Contains(string(body), exp), "exp %q to be contained in %q", exp, string(body)) vcsClient.VerifyWasCalled(Never()).CreateComment(matchers.AnyModelsRepo(), AnyInt(), AnyString(), AnyString()) @@ -645,7 +646,7 @@ func TestPost_BBServerPullClosed(t *testing.T) { } // Build HTTP request. - requestBytes, err := ioutil.ReadFile(filepath.Join("testfixtures", "bb-server-pull-deleted-event.json")) + requestBytes, err := os.ReadFile(filepath.Join("testfixtures", "bb-server-pull-deleted-event.json")) // Replace the eventKey field with our event type. requestJSON := strings.Replace(string(requestBytes), `"eventKey":"pr:deleted",`, fmt.Sprintf(`"eventKey":"%s",`, c.header), -1) Ok(t, err) diff --git a/server/controllers/events/github_request_validator.go b/server/controllers/events/github_request_validator.go index 0d5845c1e2..9a7ffc19ba 100644 --- a/server/controllers/events/github_request_validator.go +++ b/server/controllers/events/github_request_validator.go @@ -16,7 +16,7 @@ package events import ( "errors" "fmt" - "io/ioutil" + "io" "net/http" "github.com/google/go-github/v31/github" @@ -60,7 +60,7 @@ func (d *DefaultGithubRequestValidator) validateAgainstSecret(r *http.Request, s func (d *DefaultGithubRequestValidator) validateWithoutSecret(r *http.Request) ([]byte, error) { switch ct := r.Header.Get("Content-Type"); ct { case "application/json": - payload, err := ioutil.ReadAll(r.Body) + payload, err := io.ReadAll(r.Body) if err != nil { return nil, fmt.Errorf("could not read body: %s", err) } diff --git a/server/controllers/events/gitlab_request_parser_validator.go b/server/controllers/events/gitlab_request_parser_validator.go index f1bffccebb..9755bd5d9e 100644 --- a/server/controllers/events/gitlab_request_parser_validator.go +++ b/server/controllers/events/gitlab_request_parser_validator.go @@ -16,7 +16,7 @@ package events import ( "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" gitlab "github.com/xanzy/go-gitlab" @@ -68,7 +68,7 @@ func (d *DefaultGitlabRequestParserValidator) ParseAndValidate(r *http.Request, // Parse request into a gitlab object based on the object type specified // in the gitlabHeader. - bytes, err := ioutil.ReadAll(r.Body) + bytes, err := io.ReadAll(r.Body) if err != nil { return nil, err } diff --git a/server/controllers/status_controller_test.go b/server/controllers/status_controller_test.go index e809099e1a..bc51611558 100644 --- a/server/controllers/status_controller_test.go +++ b/server/controllers/status_controller_test.go @@ -3,7 +3,7 @@ package controllers_test import ( "bytes" "encoding/json" - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -26,7 +26,7 @@ func TestStatusController_Startup(t *testing.T) { d.Get(w, r) var result controllers.StatusResponse - body, err := ioutil.ReadAll(w.Result().Body) + body, err := io.ReadAll(w.Result().Body) Ok(t, err) Equals(t, 200, w.Result().StatusCode) err = json.Unmarshal(body, &result) @@ -49,7 +49,7 @@ func TestStatusController_InProgress(t *testing.T) { d.Get(w, r) var result controllers.StatusResponse - body, err := ioutil.ReadAll(w.Result().Body) + body, err := io.ReadAll(w.Result().Body) Ok(t, err) Equals(t, 200, w.Result().StatusCode) err = json.Unmarshal(body, &result) @@ -72,7 +72,7 @@ func TestStatusController_Shutdown(t *testing.T) { d.Get(w, r) var result controllers.StatusResponse - body, err := ioutil.ReadAll(w.Result().Body) + body, err := io.ReadAll(w.Result().Body) Ok(t, err) Equals(t, 200, w.Result().StatusCode) err = json.Unmarshal(body, &result) diff --git a/server/core/db/boltdb_test.go b/server/core/db/boltdb_test.go index ca41c6c00b..24b0342f70 100644 --- a/server/core/db/boltdb_test.go +++ b/server/core/db/boltdb_test.go @@ -14,7 +14,6 @@ package db_test import ( - "io/ioutil" "os" "testing" "time" @@ -769,7 +768,7 @@ func TestPullStatus_UpdateMerge(t *testing.T) { // newTestDB returns a TestDB using a temporary path. func newTestDB() (*bolt.DB, *db.BoltDB) { // Retrieve a temporary path. - f, err := ioutil.TempFile("", "") + f, err := os.CreateTemp("", "") if err != nil { panic(errors.Wrap(err, "failed to create temp file")) } diff --git a/server/core/runtime/apply_step_runner.go b/server/core/runtime/apply_step_runner.go index 3ce0d79ca9..d4bcd90c69 100644 --- a/server/core/runtime/apply_step_runner.go +++ b/server/core/runtime/apply_step_runner.go @@ -2,7 +2,6 @@ package runtime import ( "fmt" - "io/ioutil" "os" "path/filepath" "reflect" @@ -27,7 +26,7 @@ func (a *ApplyStepRunner) Run(ctx models.ProjectCommandContext, extraArgs []stri } planPath := filepath.Join(path, GetPlanFilename(ctx.Workspace, ctx.ProjectName)) - contents, err := ioutil.ReadFile(planPath) + contents, err := os.ReadFile(planPath) if os.IsNotExist(err) { return "", fmt.Errorf("no plan found at path %q and workspace %q–did you run plan?", ctx.RepoRelDir, ctx.Workspace) } @@ -118,7 +117,7 @@ func (a *ApplyStepRunner) runRemoteApply( // The planfile contents are needed to ensure that the plan didn't change // between plan and apply phases. - planfileBytes, err := ioutil.ReadFile(absPlanPath) + planfileBytes, err := os.ReadFile(absPlanPath) if err != nil { return "", errors.Wrap(err, "reading planfile") } diff --git a/server/core/runtime/apply_step_runner_test.go b/server/core/runtime/apply_step_runner_test.go index 2130f4a816..7010f79d6a 100644 --- a/server/core/runtime/apply_step_runner_test.go +++ b/server/core/runtime/apply_step_runner_test.go @@ -3,7 +3,6 @@ package runtime_test import ( "errors" "fmt" - "io/ioutil" "os" "path/filepath" "strings" @@ -52,7 +51,7 @@ func TestRun_Success(t *testing.T) { tmpDir, cleanup := TempDir(t) defer cleanup() planPath := filepath.Join(tmpDir, "workspace.tfplan") - err := ioutil.WriteFile(planPath, nil, 0600) + err := os.WriteFile(planPath, nil, 0600) Ok(t, err) RegisterMockTestingT(t) @@ -82,7 +81,7 @@ func TestRun_AppliesCorrectProjectPlan(t *testing.T) { tmpDir, cleanup := TempDir(t) defer cleanup() planPath := filepath.Join(tmpDir, "projectname-default.tfplan") - err := ioutil.WriteFile(planPath, nil, 0600) + err := os.WriteFile(planPath, nil, 0600) Ok(t, err) RegisterMockTestingT(t) @@ -112,7 +111,7 @@ func TestRun_UsesConfiguredTFVersion(t *testing.T) { tmpDir, cleanup := TempDir(t) defer cleanup() planPath := filepath.Join(tmpDir, "workspace.tfplan") - err := ioutil.WriteFile(planPath, nil, 0600) + err := os.WriteFile(planPath, nil, 0600) Ok(t, err) RegisterMockTestingT(t) @@ -197,7 +196,7 @@ func TestRun_UsingTarget(t *testing.T) { tmpDir, cleanup := TempDir(t) defer cleanup() planPath := filepath.Join(tmpDir, "workspace.tfplan") - err := ioutil.WriteFile(planPath, nil, 0600) + err := os.WriteFile(planPath, nil, 0600) Ok(t, err) terraform := mocks.NewMockClient() step := runtime.ApplyStepRunner{ @@ -236,7 +235,7 @@ Terraform will perform the following actions: Plan: 0 to add, 0 to change, 1 to destroy.` - err := ioutil.WriteFile(planPath, []byte("Atlantis: this plan was created by remote ops\n"+planFileContents), 0600) + err := os.WriteFile(planPath, []byte("Atlantis: this plan was created by remote ops\n"+planFileContents), 0600) Ok(t, err) RegisterMockTestingT(t) @@ -294,7 +293,7 @@ Terraform will perform the following actions: Plan: 0 to add, 0 to change, 1 to destroy.` - err := ioutil.WriteFile(planPath, []byte("Atlantis: this plan was created by remote ops\n"+planFileContents), 0600) + err := os.WriteFile(planPath, []byte("Atlantis: this plan was created by remote ops\n"+planFileContents), 0600) Ok(t, err) RegisterMockTestingT(t) diff --git a/server/core/runtime/init_step_runner_test.go b/server/core/runtime/init_step_runner_test.go index 496f13f7a7..9c839e0e4f 100644 --- a/server/core/runtime/init_step_runner_test.go +++ b/server/core/runtime/init_step_runner_test.go @@ -1,7 +1,7 @@ package runtime_test import ( - "io/ioutil" + "os" "os/exec" "path/filepath" "strings" @@ -106,7 +106,7 @@ func TestRun_InitOmitsUpgradeFlagIfLockFileTracked(t *testing.T) { defer cleanup() lockFilePath := filepath.Join(repoDir, ".terraform.lock.hcl") - err := ioutil.WriteFile(lockFilePath, nil, 0600) + err := os.WriteFile(lockFilePath, nil, 0600) Ok(t, err) // commit lock file runCmd(t, repoDir, "git", "add", ".terraform.lock.hcl") @@ -172,7 +172,7 @@ func TestRun_InitKeepUpgradeFlagIfLockFilePresentAndTFLessThanPoint14(t *testing tmpDir, cleanup := TempDir(t) defer cleanup() lockFilePath := filepath.Join(tmpDir, ".terraform.lock.hcl") - err := ioutil.WriteFile(lockFilePath, nil, 0600) + err := os.WriteFile(lockFilePath, nil, 0600) Ok(t, err) RegisterMockTestingT(t) @@ -274,7 +274,7 @@ func TestRun_InitDeletesLockFileIfPresentAndNotTracked(t *testing.T) { defer cleanup() lockFilePath := filepath.Join(repoDir, ".terraform.lock.hcl") - err := ioutil.WriteFile(lockFilePath, nil, 0600) + err := os.WriteFile(lockFilePath, nil, 0600) Ok(t, err) RegisterMockTestingT(t) diff --git a/server/core/runtime/plan_step_runner.go b/server/core/runtime/plan_step_runner.go index ea21139e11..8ac365003c 100644 --- a/server/core/runtime/plan_step_runner.go +++ b/server/core/runtime/plan_step_runner.go @@ -2,7 +2,6 @@ package runtime import ( "fmt" - "io/ioutil" "os" "path/filepath" "regexp" @@ -92,7 +91,7 @@ func (p *PlanStepRunner) remotePlan(ctx models.ProjectCommandContext, extraArgs // We also prepend our own remote ops header to the file so during apply we // know this is a remote apply. - err = ioutil.WriteFile(planFile, []byte(remoteOpsHeader+planOutput), 0600) + err = os.WriteFile(planFile, []byte(remoteOpsHeader+planOutput), 0600) if err != nil { return output, errors.Wrap(err, "unable to create planfile for remote ops") } diff --git a/server/core/runtime/plan_step_runner_test.go b/server/core/runtime/plan_step_runner_test.go index d16d531a30..f4a19fbb44 100644 --- a/server/core/runtime/plan_step_runner_test.go +++ b/server/core/runtime/plan_step_runner_test.go @@ -2,7 +2,6 @@ package runtime_test import ( "fmt" - "io/ioutil" "os" "path/filepath" "strings" @@ -386,7 +385,7 @@ func TestRun_AddsEnvVarFile(t *testing.T) { err := os.MkdirAll(filepath.Join(tmpDir, "env"), 0700) Ok(t, err) envVarsFile := filepath.Join(tmpDir, "env/workspace.tfvars") - err = ioutil.WriteFile(envVarsFile, nil, 0600) + err = os.WriteFile(envVarsFile, nil, 0600) Ok(t, err) // Using version >= 0.10 here so we don't expect any env commands. @@ -795,7 +794,7 @@ Plan: 0 to add, 0 to change, 1 to destroy.`, output) Equals(t, expRemotePlanArgs, asyncTf.CalledArgs) // Verify that the fake plan file we write has the correct contents. - bytes, err := ioutil.ReadFile(filepath.Join(absProjectPath, "default.tfplan")) + bytes, err := os.ReadFile(filepath.Join(absProjectPath, "default.tfplan")) Ok(t, err) Equals(t, `Atlantis: this plan was created by remote ops diff --git a/server/core/runtime/plan_type_step_runner_delegate.go b/server/core/runtime/plan_type_step_runner_delegate.go index a372cd2e00..d2cef7a2d8 100644 --- a/server/core/runtime/plan_type_step_runner_delegate.go +++ b/server/core/runtime/plan_type_step_runner_delegate.go @@ -1,7 +1,7 @@ package runtime import ( - "io/ioutil" + "os" "path/filepath" "github.com/pkg/errors" @@ -40,7 +40,7 @@ type PlanTypeStepRunnerDelegate struct { } func (p *PlanTypeStepRunnerDelegate) isRemotePlan(planFile string) (bool, error) { - data, err := ioutil.ReadFile(planFile) + data, err := os.ReadFile(planFile) if err != nil { return false, errors.Wrapf(err, "unable to read %s", planFile) diff --git a/server/core/runtime/plan_type_step_runner_delegate_test.go b/server/core/runtime/plan_type_step_runner_delegate_test.go index 060e163a68..189f171de9 100644 --- a/server/core/runtime/plan_type_step_runner_delegate_test.go +++ b/server/core/runtime/plan_type_step_runner_delegate_test.go @@ -2,7 +2,7 @@ package runtime import ( "errors" - "io/ioutil" + "os" "path/filepath" "testing" @@ -44,7 +44,7 @@ func TestRunDelegate(t *testing.T) { tmpDir, cleanup := TempDir(t) defer cleanup() planPath := filepath.Join(tmpDir, "workspace.tfplan") - err := ioutil.WriteFile(planPath, []byte("Atlantis: this plan was created by remote ops\n"+planFileContents), 0600) + err := os.WriteFile(planPath, []byte("Atlantis: this plan was created by remote ops\n"+planFileContents), 0600) Ok(t, err) ctx := models.ProjectCommandContext{ @@ -73,7 +73,7 @@ func TestRunDelegate(t *testing.T) { tmpDir, cleanup := TempDir(t) defer cleanup() planPath := filepath.Join(tmpDir, "workspace.tfplan") - err := ioutil.WriteFile(planPath, []byte("Atlantis: this plan was created by remote ops\n"+planFileContents), 0600) + err := os.WriteFile(planPath, []byte("Atlantis: this plan was created by remote ops\n"+planFileContents), 0600) Ok(t, err) ctx := models.ProjectCommandContext{ @@ -102,7 +102,7 @@ func TestRunDelegate(t *testing.T) { tmpDir, cleanup := TempDir(t) defer cleanup() planPath := filepath.Join(tmpDir, "workspace.tfplan") - err := ioutil.WriteFile(planPath, []byte(planFileContents), 0600) + err := os.WriteFile(planPath, []byte(planFileContents), 0600) Ok(t, err) ctx := models.ProjectCommandContext{ @@ -131,7 +131,7 @@ func TestRunDelegate(t *testing.T) { tmpDir, cleanup := TempDir(t) defer cleanup() planPath := filepath.Join(tmpDir, "workspace.tfplan") - err := ioutil.WriteFile(planPath, []byte(planFileContents), 0600) + err := os.WriteFile(planPath, []byte(planFileContents), 0600) Ok(t, err) ctx := models.ProjectCommandContext{ diff --git a/server/core/runtime/show_step_runner.go b/server/core/runtime/show_step_runner.go index 7464636ecd..a8f0e398ed 100644 --- a/server/core/runtime/show_step_runner.go +++ b/server/core/runtime/show_step_runner.go @@ -1,7 +1,6 @@ package runtime import ( - "io/ioutil" "os" "path/filepath" @@ -52,7 +51,7 @@ func (p *ShowStepRunner) Run(ctx models.ProjectCommandContext, extraArgs []strin return "", errors.Wrap(err, "running terraform show") } - if err := ioutil.WriteFile(showResultFile, []byte(output), os.ModePerm); err != nil { + if err := os.WriteFile(showResultFile, []byte(output), os.ModePerm); err != nil { return "", errors.Wrap(err, "writing terraform show result") } diff --git a/server/core/runtime/show_step_runner_test.go b/server/core/runtime/show_step_runner_test.go index a01d8fb503..264d768ccb 100644 --- a/server/core/runtime/show_step_runner_test.go +++ b/server/core/runtime/show_step_runner_test.go @@ -2,7 +2,7 @@ package runtime import ( "errors" - "io/ioutil" + "os" "path/filepath" "testing" @@ -16,7 +16,7 @@ import ( func TestShowStepRunnner(t *testing.T) { logger := logging.NewNoopLogger(t) - path, _ := ioutil.TempDir("", "") + path, _ := os.MkdirTemp("", "") resultPath := filepath.Join(path, "test-default.json") envs := map[string]string{"key": "val"} tfVersion, _ := version.NewVersion("0.12") @@ -45,7 +45,7 @@ func TestShowStepRunnner(t *testing.T) { Ok(t, err) - actual, _ := ioutil.ReadFile(resultPath) + actual, _ := os.ReadFile(resultPath) actualStr := string(actual) Assert(t, actualStr == "success", "got expected result") @@ -72,7 +72,7 @@ func TestShowStepRunnner(t *testing.T) { Ok(t, err) - actual, _ := ioutil.ReadFile(resultPath) + actual, _ := os.ReadFile(resultPath) actualStr := string(actual) Assert(t, actualStr == "success", "got expected result") diff --git a/server/core/terraform/terraform_client.go b/server/core/terraform/terraform_client.go index 971eeb3c4a..39defed68c 100644 --- a/server/core/terraform/terraform_client.go +++ b/server/core/terraform/terraform_client.go @@ -18,7 +18,6 @@ import ( "bufio" "fmt" "io" - "io/ioutil" "os" "os/exec" "path/filepath" @@ -491,7 +490,7 @@ func generateRCFile(tfeToken string, tfeHostname string, home string) error { // what we would have written to it, then we error out because we don't // want to overwrite anything. if _, err := os.Stat(rcFile); err == nil { - currContents, err := ioutil.ReadFile(rcFile) // nolint: gosec + currContents, err := os.ReadFile(rcFile) // nolint: gosec if err != nil { return errors.Wrapf(err, "trying to read %s to ensure we're not overwriting it", rcFile) } @@ -503,7 +502,7 @@ func generateRCFile(tfeToken string, tfeHostname string, home string) error { return nil } - if err := ioutil.WriteFile(rcFile, []byte(config), 0600); err != nil { + if err := os.WriteFile(rcFile, []byte(config), 0600); err != nil { return errors.Wrapf(err, "writing generated %s file with TFE token to %s", rcFilename, rcFile) } return nil diff --git a/server/core/terraform/terraform_client_internal_test.go b/server/core/terraform/terraform_client_internal_test.go index 8a447fb828..036f08766a 100644 --- a/server/core/terraform/terraform_client_internal_test.go +++ b/server/core/terraform/terraform_client_internal_test.go @@ -2,7 +2,6 @@ package terraform import ( "fmt" - "io/ioutil" "os" "path/filepath" "strings" @@ -24,7 +23,7 @@ func TestGenerateRCFile_WritesFile(t *testing.T) { expContents := `credentials "hostname" { token = "token" }` - actContents, err := ioutil.ReadFile(filepath.Join(tmp, ".terraformrc")) + actContents, err := os.ReadFile(filepath.Join(tmp, ".terraformrc")) Ok(t, err) Equals(t, expContents, string(actContents)) } @@ -36,7 +35,7 @@ func TestGenerateRCFile_WillNotOverwrite(t *testing.T) { defer cleanup() rcFile := filepath.Join(tmp, ".terraformrc") - err := ioutil.WriteFile(rcFile, []byte("contents"), 0600) + err := os.WriteFile(rcFile, []byte("contents"), 0600) Ok(t, err) actErr := generateRCFile("token", "hostname", tmp) @@ -54,7 +53,7 @@ func TestGenerateRCFile_NoErrIfContentsSame(t *testing.T) { contents := `credentials "app.terraform.io" { token = "token" }` - err := ioutil.WriteFile(rcFile, []byte(contents), 0600) + err := os.WriteFile(rcFile, []byte(contents), 0600) Ok(t, err) err = generateRCFile("token", "app.terraform.io", tmp) @@ -68,7 +67,7 @@ func TestGenerateRCFile_ErrIfCannotRead(t *testing.T) { defer cleanup() rcFile := filepath.Join(tmp, ".terraformrc") - err := ioutil.WriteFile(rcFile, []byte("can't see me!"), 0000) + err := os.WriteFile(rcFile, []byte("can't see me!"), 0000) Ok(t, err) expErr := fmt.Sprintf("trying to read %s to ensure we're not overwriting it: open %s: permission denied", rcFile, rcFile) diff --git a/server/core/terraform/terraform_client_test.go b/server/core/terraform/terraform_client_test.go index 5ccb2e5734..dc8203806a 100644 --- a/server/core/terraform/terraform_client_test.go +++ b/server/core/terraform/terraform_client_test.go @@ -15,7 +15,6 @@ package terraform_test import ( "fmt" - "io/ioutil" "os" "path/filepath" "runtime" @@ -66,7 +65,7 @@ is 0.11.13. You can update by downloading from www.terraform.io/downloads.html // We're testing this by adding our own "fake" terraform binary to path that // outputs what would normally come from terraform version. - err := ioutil.WriteFile(filepath.Join(tmp, "terraform"), []byte(fmt.Sprintf("#!/bin/sh\necho '%s'", fakeBinOut)), 0700) // #nosec G306 + err := os.WriteFile(filepath.Join(tmp, "terraform"), []byte(fmt.Sprintf("#!/bin/sh\necho '%s'", fakeBinOut)), 0700) // #nosec G306 Ok(t, err) defer tempSetEnv(t, "PATH", fmt.Sprintf("%s:%s", tmp, os.Getenv("PATH")))() @@ -95,7 +94,7 @@ is 0.11.13. You can update by downloading from www.terraform.io/downloads.html // We're testing this by adding our own "fake" terraform binary to path that // outputs what would normally come from terraform version. - err := ioutil.WriteFile(filepath.Join(tmp, "terraform"), []byte(fmt.Sprintf("#!/bin/sh\necho '%s'", fakeBinOut)), 0700) // #nosec G306 + err := os.WriteFile(filepath.Join(tmp, "terraform"), []byte(fmt.Sprintf("#!/bin/sh\necho '%s'", fakeBinOut)), 0700) // #nosec G306 Ok(t, err) defer tempSetEnv(t, "PATH", fmt.Sprintf("%s:%s", tmp, os.Getenv("PATH")))() @@ -134,7 +133,7 @@ func TestNewClient_DefaultTFFlagInPath(t *testing.T) { // We're testing this by adding our own "fake" terraform binary to path that // outputs what would normally come from terraform version. - err := ioutil.WriteFile(filepath.Join(tmp, "terraform0.11.10"), []byte(fmt.Sprintf("#!/bin/sh\necho '%s'", fakeBinOut)), 0700) // #nosec G306 + err := os.WriteFile(filepath.Join(tmp, "terraform0.11.10"), []byte(fmt.Sprintf("#!/bin/sh\necho '%s'", fakeBinOut)), 0700) // #nosec G306 Ok(t, err) defer tempSetEnv(t, "PATH", fmt.Sprintf("%s:%s", tmp, os.Getenv("PATH")))() @@ -158,7 +157,7 @@ func TestNewClient_DefaultTFFlagInBinDir(t *testing.T) { defer cleanup() // Add our fake binary to {datadir}/bin/terraform{version}. - err := ioutil.WriteFile(filepath.Join(binDir, "terraform0.11.10"), []byte(fmt.Sprintf("#!/bin/sh\necho '%s'", fakeBinOut)), 0700) // #nosec G306 + err := os.WriteFile(filepath.Join(binDir, "terraform0.11.10"), []byte(fmt.Sprintf("#!/bin/sh\necho '%s'", fakeBinOut)), 0700) // #nosec G306 Ok(t, err) defer tempSetEnv(t, "PATH", fmt.Sprintf("%s:%s", tmp, os.Getenv("PATH")))() @@ -186,7 +185,7 @@ func TestNewClient_DefaultTFFlagDownload(t *testing.T) { mockDownloader := mocks.NewMockDownloader() When(mockDownloader.GetFile(AnyString(), AnyString())).Then(func(params []pegomock.Param) pegomock.ReturnValues { - err := ioutil.WriteFile(params[0].(string), []byte("#!/bin/sh\necho '\nTerraform v0.11.10\n'"), 0700) // #nosec G306 + err := os.WriteFile(params[0].(string), []byte("#!/bin/sh\necho '\nTerraform v0.11.10\n'"), 0700) // #nosec G306 return []pegomock.ReturnValue{err} }) c, err := terraform.NewClient(logger, binDir, cacheDir, "", "", "0.11.10", cmd.DefaultTFVersionFlag, "https://my-mirror.releases.mycompany.com", mockDownloader, true) @@ -234,7 +233,7 @@ func TestRunCommandWithVersion_DLsTF(t *testing.T) { runtime.GOARCH, baseURL) When(mockDownloader.GetFile(filepath.Join(tmp, "bin", "terraform99.99.99"), expURL)).Then(func(params []pegomock.Param) pegomock.ReturnValues { - err := ioutil.WriteFile(params[0].(string), []byte("#!/bin/sh\necho '\nTerraform v99.99.99\n'"), 0700) // #nosec G306 + err := os.WriteFile(params[0].(string), []byte("#!/bin/sh\necho '\nTerraform v99.99.99\n'"), 0700) // #nosec G306 return []pegomock.ReturnValue{err} }) diff --git a/server/events/comment_parser.go b/server/events/comment_parser.go index 395516895c..515737568a 100644 --- a/server/events/comment_parser.go +++ b/server/events/comment_parser.go @@ -16,7 +16,7 @@ package events import ( "bytes" "fmt" - "io/ioutil" + "io" "net/url" "path/filepath" "regexp" @@ -183,7 +183,7 @@ func (e *CommentParser) Parse(comment string, vcsHost models.VCSHostType) Commen case models.PlanCommand.String(): name = models.PlanCommand flagSet = pflag.NewFlagSet(models.PlanCommand.String(), pflag.ContinueOnError) - flagSet.SetOutput(ioutil.Discard) + flagSet.SetOutput(io.Discard) flagSet.StringVarP(&workspace, workspaceFlagLong, workspaceFlagShort, "", "Switch to this Terraform workspace before planning.") flagSet.StringVarP(&dir, dirFlagLong, dirFlagShort, "", "Which directory to run plan in relative to root of repo, ex. 'child/dir'.") flagSet.StringVarP(&project, projectFlagLong, projectFlagShort, "", fmt.Sprintf("Which project to run plan for. Refers to the name of the project configured in %s. Cannot be used at same time as workspace or dir flags.", yaml.AtlantisYAMLFilename)) @@ -191,7 +191,7 @@ func (e *CommentParser) Parse(comment string, vcsHost models.VCSHostType) Commen case models.ApplyCommand.String(): name = models.ApplyCommand flagSet = pflag.NewFlagSet(models.ApplyCommand.String(), pflag.ContinueOnError) - flagSet.SetOutput(ioutil.Discard) + flagSet.SetOutput(io.Discard) flagSet.StringVarP(&workspace, workspaceFlagLong, workspaceFlagShort, "", "Apply the plan for this Terraform workspace.") flagSet.StringVarP(&dir, dirFlagLong, dirFlagShort, "", "Apply the plan for this directory, relative to root of repo, ex. 'child/dir'.") flagSet.StringVarP(&project, projectFlagLong, projectFlagShort, "", fmt.Sprintf("Apply the plan for this project. Refers to the name of the project configured in %s. Cannot be used at same time as workspace or dir flags.", yaml.AtlantisYAMLFilename)) @@ -200,12 +200,12 @@ func (e *CommentParser) Parse(comment string, vcsHost models.VCSHostType) Commen case models.ApprovePoliciesCommand.String(): name = models.ApprovePoliciesCommand flagSet = pflag.NewFlagSet(models.ApprovePoliciesCommand.String(), pflag.ContinueOnError) - flagSet.SetOutput(ioutil.Discard) + flagSet.SetOutput(io.Discard) flagSet.BoolVarP(&verbose, verboseFlagLong, verboseFlagShort, false, "Append Atlantis log to comment.") case models.UnlockCommand.String(): name = models.UnlockCommand flagSet = pflag.NewFlagSet(models.UnlockCommand.String(), pflag.ContinueOnError) - flagSet.SetOutput(ioutil.Discard) + flagSet.SetOutput(io.Discard) case models.VersionCommand.String(): name = models.VersionCommand flagSet = pflag.NewFlagSet(models.VersionCommand.String(), pflag.ContinueOnError) diff --git a/server/events/event_parser_test.go b/server/events/event_parser_test.go index 1922de084f..c98fcd8ab5 100644 --- a/server/events/event_parser_test.go +++ b/server/events/event_parser_test.go @@ -16,7 +16,7 @@ package events_test import ( "encoding/json" "fmt" - "io/ioutil" + "os" "path/filepath" "strings" "testing" @@ -325,7 +325,7 @@ func TestParseGithubPull(t *testing.T) { func TestParseGitlabMergeEvent(t *testing.T) { t.Log("should properly parse a gitlab merge event") path := filepath.Join("testdata", "gitlab-merge-request-event.json") - bytes, err := ioutil.ReadFile(path) + bytes, err := os.ReadFile(path) Ok(t, err) var event *gitlab.MergeEvent err = json.Unmarshal(bytes, &event) @@ -382,7 +382,7 @@ func TestParseGitlabMergeEvent(t *testing.T) { // i.e. instead of under an owner/repo it's under an owner/group/subgroup/repo. func TestParseGitlabMergeEvent_Subgroup(t *testing.T) { path := filepath.Join("testdata", "gitlab-merge-request-event-subgroup.json") - bytes, err := ioutil.ReadFile(path) + bytes, err := os.ReadFile(path) Ok(t, err) var event *gitlab.MergeEvent err = json.Unmarshal(bytes, &event) @@ -457,7 +457,7 @@ func TestParseGitlabMergeEvent_ActionType(t *testing.T) { } path := filepath.Join("testdata", "gitlab-merge-request-event.json") - bytes, err := ioutil.ReadFile(path) + bytes, err := os.ReadFile(path) Ok(t, err) mergeEventJSON := string(bytes) @@ -479,7 +479,7 @@ func TestParseGitlabMergeEvent_ActionType(t *testing.T) { func TestParseGitlabMergeRequest(t *testing.T) { t.Log("should properly parse a gitlab merge request") path := filepath.Join("testdata", "gitlab-get-merge-request.json") - bytes, err := ioutil.ReadFile(path) + bytes, err := os.ReadFile(path) if err != nil { Ok(t, err) } @@ -517,7 +517,7 @@ func TestParseGitlabMergeRequest(t *testing.T) { func TestParseGitlabMergeRequest_Subgroup(t *testing.T) { path := filepath.Join("testdata", "gitlab-get-merge-request-subgroup.json") - bytes, err := ioutil.ReadFile(path) + bytes, err := os.ReadFile(path) if err != nil { Ok(t, err) } @@ -552,7 +552,7 @@ func TestParseGitlabMergeRequest_Subgroup(t *testing.T) { func TestParseGitlabMergeCommentEvent(t *testing.T) { t.Log("should properly parse a gitlab merge comment event") path := filepath.Join("testdata", "gitlab-merge-request-comment-event.json") - bytes, err := ioutil.ReadFile(path) + bytes, err := os.ReadFile(path) Ok(t, err) var event *gitlab.MergeCommentEvent err = json.Unmarshal(bytes, &event) @@ -589,7 +589,7 @@ func TestParseGitlabMergeCommentEvent(t *testing.T) { // Should properly parse a gitlab merge comment event from a subgroup repo. func TestParseGitlabMergeCommentEvent_Subgroup(t *testing.T) { path := filepath.Join("testdata", "gitlab-merge-request-comment-event-subgroup.json") - bytes, err := ioutil.ReadFile(path) + bytes, err := os.ReadFile(path) Ok(t, err) var event *gitlab.MergeCommentEvent err = json.Unmarshal(bytes, &event) @@ -738,7 +738,7 @@ func TestParseBitbucketCloudCommentEvent_EmptyObject(t *testing.T) { func TestParseBitbucketCloudCommentEvent_CommitHashMissing(t *testing.T) { path := filepath.Join("testdata", "bitbucket-cloud-comment-event.json") - bytes, err := ioutil.ReadFile(path) + bytes, err := os.ReadFile(path) Ok(t, err) emptyCommitHash := strings.Replace(string(bytes), ` "hash": "e0624da46d3a",`, "", -1) _, _, _, _, _, err = parser.ParseBitbucketCloudPullCommentEvent([]byte(emptyCommitHash)) @@ -747,7 +747,7 @@ func TestParseBitbucketCloudCommentEvent_CommitHashMissing(t *testing.T) { func TestParseBitbucketCloudCommentEvent_ValidEvent(t *testing.T) { path := filepath.Join("testdata", "bitbucket-cloud-comment-event.json") - bytes, err := ioutil.ReadFile(path) + bytes, err := os.ReadFile(path) Ok(t, err) pull, baseRepo, headRepo, user, comment, err := parser.ParseBitbucketCloudPullCommentEvent(bytes) Ok(t, err) @@ -792,7 +792,7 @@ func TestParseBitbucketCloudCommentEvent_ValidEvent(t *testing.T) { func TestParseBitbucketCloudCommentEvent_MultipleStates(t *testing.T) { path := filepath.Join("testdata", "bitbucket-cloud-comment-event.json") - bytes, err := ioutil.ReadFile(path) + bytes, err := os.ReadFile(path) if err != nil { Ok(t, err) } @@ -831,7 +831,7 @@ func TestParseBitbucketCloudCommentEvent_MultipleStates(t *testing.T) { func TestParseBitbucketCloudPullEvent_ValidEvent(t *testing.T) { path := filepath.Join("testdata", "bitbucket-cloud-pull-event-created.json") - bytes, err := ioutil.ReadFile(path) + bytes, err := os.ReadFile(path) if err != nil { Ok(t, err) } @@ -894,7 +894,7 @@ func TestParseBitbucketCloudPullEvent_States(t *testing.T) { }, } { path := filepath.Join("testdata", c.JSON) - bytes, err := ioutil.ReadFile(path) + bytes, err := os.ReadFile(path) if err != nil { Ok(t, err) } @@ -950,7 +950,7 @@ func TestParseBitbucketServerCommentEvent_EmptyObject(t *testing.T) { func TestParseBitbucketServerCommentEvent_CommitHashMissing(t *testing.T) { path := filepath.Join("testdata", "bitbucket-server-comment-event.json") - bytes, err := ioutil.ReadFile(path) + bytes, err := os.ReadFile(path) if err != nil { Ok(t, err) } @@ -961,7 +961,7 @@ func TestParseBitbucketServerCommentEvent_CommitHashMissing(t *testing.T) { func TestParseBitbucketServerCommentEvent_ValidEvent(t *testing.T) { path := filepath.Join("testdata", "bitbucket-server-comment-event.json") - bytes, err := ioutil.ReadFile(path) + bytes, err := os.ReadFile(path) if err != nil { Ok(t, err) } @@ -1008,7 +1008,7 @@ func TestParseBitbucketServerCommentEvent_ValidEvent(t *testing.T) { func TestParseBitbucketServerCommentEvent_MultipleStates(t *testing.T) { path := filepath.Join("testdata", "bitbucket-server-comment-event.json") - bytes, err := ioutil.ReadFile(path) + bytes, err := os.ReadFile(path) if err != nil { Ok(t, err) } @@ -1043,7 +1043,7 @@ func TestParseBitbucketServerCommentEvent_MultipleStates(t *testing.T) { func TestParseBitbucketServerPullEvent_ValidEvent(t *testing.T) { path := filepath.Join("testdata", "bitbucket-server-pull-event-merged.json") - bytes, err := ioutil.ReadFile(path) + bytes, err := os.ReadFile(path) if err != nil { Ok(t, err) } diff --git a/server/events/git_cred_writer.go b/server/events/git_cred_writer.go index 1eea384c2d..b8e83facb9 100644 --- a/server/events/git_cred_writer.go +++ b/server/events/git_cred_writer.go @@ -2,7 +2,6 @@ package events import ( "fmt" - "io/ioutil" "os" "os/exec" "path/filepath" @@ -24,7 +23,7 @@ func WriteGitCreds(gitUser string, gitToken string, gitHostname string, home str // If the file doesn't exist, write it. if _, err := os.Stat(credsFile); err != nil { - if err := ioutil.WriteFile(credsFile, []byte(config), 0600); err != nil { + if err := os.WriteFile(credsFile, []byte(config), 0600); err != nil { return errors.Wrapf(err, "writing generated %s file with user, token and hostname to %s", credsFilename, credsFile) } logger.Info("wrote git credentials to %s", credsFile) @@ -68,7 +67,7 @@ func WriteGitCreds(gitUser string, gitToken string, gitHostname string, home str } func fileHasLine(line string, filename string) (bool, error) { - currContents, err := ioutil.ReadFile(filename) // nolint: gosec + currContents, err := os.ReadFile(filename) // nolint: gosec if err != nil { return false, errors.Wrapf(err, "reading %s", filename) } @@ -81,18 +80,18 @@ func fileHasLine(line string, filename string) (bool, error) { } func fileAppend(line string, filename string) error { - currContents, err := ioutil.ReadFile(filename) // nolint: gosec + currContents, err := os.ReadFile(filename) // nolint: gosec if err != nil { return err } if len(currContents) > 0 && !strings.HasSuffix(string(currContents), "\n") { line = "\n" + line } - return ioutil.WriteFile(filename, []byte(string(currContents)+line), 0600) + return os.WriteFile(filename, []byte(string(currContents)+line), 0600) } func fileLineReplace(line, user, host, filename string) error { - currContents, err := ioutil.ReadFile(filename) // nolint: gosec + currContents, err := os.ReadFile(filename) // nolint: gosec if err != nil { return err } @@ -112,5 +111,5 @@ func fileLineReplace(line, user, host, filename string) error { return fileAppend(line, filename) } - return ioutil.WriteFile(filename, []byte(toWrite), 0600) + return os.WriteFile(filename, []byte(toWrite), 0600) } diff --git a/server/events/git_cred_writer_test.go b/server/events/git_cred_writer_test.go index c8fc9a2cc2..9d9583abbb 100644 --- a/server/events/git_cred_writer_test.go +++ b/server/events/git_cred_writer_test.go @@ -2,7 +2,7 @@ package events_test import ( "fmt" - "io/ioutil" + "os" "os/exec" "path/filepath" "testing" @@ -24,7 +24,7 @@ func TestWriteGitCreds_WriteFile(t *testing.T) { expContents := `https://user:token@hostname` - actContents, err := ioutil.ReadFile(filepath.Join(tmp, ".git-credentials")) + actContents, err := os.ReadFile(filepath.Join(tmp, ".git-credentials")) Ok(t, err) Equals(t, expContents, string(actContents)) } @@ -36,14 +36,14 @@ func TestWriteGitCreds_Appends(t *testing.T) { defer cleanup() credsFile := filepath.Join(tmp, ".git-credentials") - err := ioutil.WriteFile(credsFile, []byte("contents"), 0600) + err := os.WriteFile(credsFile, []byte("contents"), 0600) Ok(t, err) err = events.WriteGitCreds("user", "token", "hostname", tmp, logger, false) Ok(t, err) expContents := "contents\nhttps://user:token@hostname" - actContents, err := ioutil.ReadFile(filepath.Join(tmp, ".git-credentials")) + actContents, err := os.ReadFile(filepath.Join(tmp, ".git-credentials")) Ok(t, err) Equals(t, expContents, string(actContents)) } @@ -56,12 +56,12 @@ func TestWriteGitCreds_NoModification(t *testing.T) { credsFile := filepath.Join(tmp, ".git-credentials") contents := "line1\nhttps://user:token@hostname\nline2" - err := ioutil.WriteFile(credsFile, []byte(contents), 0600) + err := os.WriteFile(credsFile, []byte(contents), 0600) Ok(t, err) err = events.WriteGitCreds("user", "token", "hostname", tmp, logger, false) Ok(t, err) - actContents, err := ioutil.ReadFile(filepath.Join(tmp, ".git-credentials")) + actContents, err := os.ReadFile(filepath.Join(tmp, ".git-credentials")) Ok(t, err) Equals(t, contents, string(actContents)) } @@ -73,13 +73,13 @@ func TestWriteGitCreds_ReplaceApp(t *testing.T) { credsFile := filepath.Join(tmp, ".git-credentials") contents := "line1\nhttps://x-access-token:v1.87dddddddddddddddd@github.com\nline2" - err := ioutil.WriteFile(credsFile, []byte(contents), 0600) + err := os.WriteFile(credsFile, []byte(contents), 0600) Ok(t, err) err = events.WriteGitCreds("x-access-token", "token", "github.com", tmp, logger, true) Ok(t, err) expContets := "line1\nhttps://x-access-token:token@github.com\nline2" - actContents, err := ioutil.ReadFile(filepath.Join(tmp, ".git-credentials")) + actContents, err := os.ReadFile(filepath.Join(tmp, ".git-credentials")) Ok(t, err) Equals(t, expContets, string(actContents)) } @@ -91,13 +91,13 @@ func TestWriteGitCreds_AppendApp(t *testing.T) { credsFile := filepath.Join(tmp, ".git-credentials") contents := "" - err := ioutil.WriteFile(credsFile, []byte(contents), 0600) + err := os.WriteFile(credsFile, []byte(contents), 0600) Ok(t, err) err = events.WriteGitCreds("x-access-token", "token", "github.com", tmp, logger, true) Ok(t, err) expContets := "https://x-access-token:token@github.com" - actContents, err := ioutil.ReadFile(filepath.Join(tmp, ".git-credentials")) + actContents, err := os.ReadFile(filepath.Join(tmp, ".git-credentials")) Ok(t, err) Equals(t, expContets, string(actContents)) } @@ -109,7 +109,7 @@ func TestWriteGitCreds_ErrIfCannotRead(t *testing.T) { defer cleanup() credsFile := filepath.Join(tmp, ".git-credentials") - err := ioutil.WriteFile(credsFile, []byte("can't see me!"), 0000) + err := os.WriteFile(credsFile, []byte("can't see me!"), 0000) Ok(t, err) expErr := fmt.Sprintf("open %s: permission denied", credsFile) diff --git a/server/events/pending_plan_finder.go b/server/events/pending_plan_finder.go index bff75b6230..38b8bbdec7 100644 --- a/server/events/pending_plan_finder.go +++ b/server/events/pending_plan_finder.go @@ -1,7 +1,6 @@ package events import ( - "io/ioutil" "os" "os/exec" "path/filepath" @@ -43,7 +42,7 @@ func (p *DefaultPendingPlanFinder) Find(pullDir string) ([]PendingPlan, error) { } func (p *DefaultPendingPlanFinder) findWithAbsPaths(pullDir string) ([]PendingPlan, []string, error) { - workspaceDirs, err := ioutil.ReadDir(pullDir) + workspaceDirs, err := os.ReadDir(pullDir) if err != nil { return nil, nil, err } diff --git a/server/events/project_command_builder_internal_test.go b/server/events/project_command_builder_internal_test.go index 9d8891907e..11dd743b1f 100644 --- a/server/events/project_command_builder_internal_test.go +++ b/server/events/project_command_builder_internal_test.go @@ -1,7 +1,7 @@ package events import ( - "io/ioutil" + "os" "path/filepath" "testing" @@ -571,7 +571,7 @@ projects: // Write and parse the global config file. globalCfgPath := filepath.Join(tmp, "global.yaml") - Ok(t, ioutil.WriteFile(globalCfgPath, []byte(c.globalCfg), 0600)) + Ok(t, os.WriteFile(globalCfgPath, []byte(c.globalCfg), 0600)) parser := &yaml.ParserValidator{} globalCfgArgs := valid.GlobalCfgArgs{ AllowRepoCfg: false, @@ -583,7 +583,7 @@ projects: Ok(t, err) if c.repoCfg != "" { - Ok(t, ioutil.WriteFile(filepath.Join(tmp, "atlantis.yaml"), []byte(c.repoCfg), 0600)) + Ok(t, os.WriteFile(filepath.Join(tmp, "atlantis.yaml"), []byte(c.repoCfg), 0600)) } builder := NewProjectCommandBuilder( @@ -764,13 +764,13 @@ projects: // Write and parse the global config file. globalCfgPath := filepath.Join(tmp, "global.yaml") - Ok(t, ioutil.WriteFile(globalCfgPath, []byte(c.globalCfg), 0600)) + Ok(t, os.WriteFile(globalCfgPath, []byte(c.globalCfg), 0600)) parser := &yaml.ParserValidator{} globalCfg, err := parser.ParseGlobalCfg(globalCfgPath, valid.NewGlobalCfg(false, false, false)) Ok(t, err) if c.repoCfg != "" { - Ok(t, ioutil.WriteFile(filepath.Join(tmp, "atlantis.yaml"), []byte(c.repoCfg), 0600)) + Ok(t, os.WriteFile(filepath.Join(tmp, "atlantis.yaml"), []byte(c.repoCfg), 0600)) } builder := NewProjectCommandBuilder( @@ -970,7 +970,7 @@ workflows: // Write and parse the global config file. globalCfgPath := filepath.Join(tmp, "global.yaml") - Ok(t, ioutil.WriteFile(globalCfgPath, []byte(c.globalCfg), 0600)) + Ok(t, os.WriteFile(globalCfgPath, []byte(c.globalCfg), 0600)) parser := &yaml.ParserValidator{} globalCfgArgs := valid.GlobalCfgArgs{ AllowRepoCfg: false, @@ -983,7 +983,7 @@ workflows: Ok(t, err) if c.repoCfg != "" { - Ok(t, ioutil.WriteFile(filepath.Join(tmp, "atlantis.yaml"), []byte(c.repoCfg), 0600)) + Ok(t, os.WriteFile(filepath.Join(tmp, "atlantis.yaml"), []byte(c.repoCfg), 0600)) } builder := NewProjectCommandBuilder( diff --git a/server/events/project_command_builder_test.go b/server/events/project_command_builder_test.go index 14b43c3621..b7f32c88fc 100644 --- a/server/events/project_command_builder_test.go +++ b/server/events/project_command_builder_test.go @@ -2,7 +2,7 @@ package events_test import ( "fmt" - "io/ioutil" + "os" "path/filepath" "strings" "testing" @@ -132,7 +132,7 @@ projects: vcsClient := vcsmocks.NewMockClient() When(vcsClient.GetModifiedFiles(matchers.AnyModelsRepo(), matchers.AnyModelsPullRequest())).ThenReturn([]string{"main.tf"}, nil) if c.AtlantisYAML != "" { - err := ioutil.WriteFile(filepath.Join(tmpDir, yaml.AtlantisYAMLFilename), []byte(c.AtlantisYAML), 0600) + err := os.WriteFile(filepath.Join(tmpDir, yaml.AtlantisYAMLFilename), []byte(c.AtlantisYAML), 0600) Ok(t, err) } @@ -394,7 +394,7 @@ projects: vcsClient := vcsmocks.NewMockClient() When(vcsClient.GetModifiedFiles(matchers.AnyModelsRepo(), matchers.AnyModelsPullRequest())).ThenReturn([]string{"main.tf"}, nil) if c.AtlantisYAML != "" { - err := ioutil.WriteFile(filepath.Join(tmpDir, yaml.AtlantisYAMLFilename), []byte(c.AtlantisYAML), 0600) + err := os.WriteFile(filepath.Join(tmpDir, yaml.AtlantisYAMLFilename), []byte(c.AtlantisYAML), 0600) Ok(t, err) } @@ -545,7 +545,7 @@ projects: vcsClient := vcsmocks.NewMockClient() When(vcsClient.GetModifiedFiles(matchers.AnyModelsRepo(), matchers.AnyModelsPullRequest())).ThenReturn(c.ModifiedFiles, nil) if c.AtlantisYAML != "" { - err := ioutil.WriteFile(filepath.Join(tmpDir, yaml.AtlantisYAMLFilename), []byte(c.AtlantisYAML), 0600) + err := os.WriteFile(filepath.Join(tmpDir, yaml.AtlantisYAMLFilename), []byte(c.AtlantisYAML), 0600) Ok(t, err) } @@ -703,7 +703,7 @@ projects: - dir: . workspace: staging ` - err := ioutil.WriteFile(filepath.Join(repoDir, yaml.AtlantisYAMLFilename), []byte(yamlCfg), 0600) + err := os.WriteFile(filepath.Join(repoDir, yaml.AtlantisYAMLFilename), []byte(yamlCfg), 0600) Ok(t, err) When(workingDir.Clone( diff --git a/server/events/project_finder_test.go b/server/events/project_finder_test.go index b4e523ae3c..8135a5e931 100644 --- a/server/events/project_finder_test.go +++ b/server/events/project_finder_test.go @@ -14,7 +14,6 @@ package events_test import ( - "io/ioutil" "os" "path/filepath" "testing" @@ -46,7 +45,7 @@ func setupTmpRepos(t *testing.T) { // modules/ // main.tf var err error - nestedModules1, err = ioutil.TempDir("", "") + nestedModules1, err = os.MkdirTemp("", "") Ok(t, err) err = os.MkdirAll(filepath.Join(nestedModules1, "project1/modules"), 0700) Ok(t, err) @@ -78,7 +77,7 @@ func setupTmpRepos(t *testing.T) { // main.tf // project2/ // main.tf - topLevelModules, err = ioutil.TempDir("", "") + topLevelModules, err = os.MkdirTemp("", "") Ok(t, err) for _, path := range []string{"modules", "project1", "project2"} { err = os.MkdirAll(filepath.Join(topLevelModules, path), 0700) @@ -93,7 +92,7 @@ func setupTmpRepos(t *testing.T) { // staging.tfvars // production.tfvars // global-env-config.auto.tfvars.json - envDir, err = ioutil.TempDir("", "") + envDir, err = os.MkdirTemp("", "") Ok(t, err) err = os.MkdirAll(filepath.Join(envDir, "env"), 0700) Ok(t, err) diff --git a/server/events/vcs/azuredevops_client_test.go b/server/events/vcs/azuredevops_client_test.go index d7c40ee6c5..a9314fd036 100644 --- a/server/events/vcs/azuredevops_client_test.go +++ b/server/events/vcs/azuredevops_client_test.go @@ -3,10 +3,11 @@ package vcs_test import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "net/url" + "os" "strings" "testing" @@ -191,7 +192,7 @@ func TestAzureDevopsClient_UpdateStatus(t *testing.T) { case "/owner/project/_apis/git/repositories/repo/pullrequests/22/statuses?api-version=5.1-preview.1": gotRequest = true defer r.Body.Close() // nolint: errcheck - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) Ok(t, err) exp := fmt.Sprintf(partResponse, c.expState) if c.supportsIterations == true { @@ -361,10 +362,10 @@ func TestAzureDevopsClient_PullIsMergeable(t *testing.T) { }, } - jsonPullRequestBytes, err := ioutil.ReadFile("fixtures/azuredevops-pr.json") + jsonPullRequestBytes, err := os.ReadFile("fixtures/azuredevops-pr.json") Ok(t, err) - jsonPolicyEvaluationBytes, err := ioutil.ReadFile("fixtures/azuredevops-policyevaluations.json") + jsonPolicyEvaluationBytes, err := os.ReadFile("fixtures/azuredevops-policyevaluations.json") Ok(t, err) pullRequestBody := string(jsonPullRequestBytes) @@ -465,7 +466,7 @@ func TestAzureDevopsClient_PullIsApproved(t *testing.T) { }, } - jsBytes, err := ioutil.ReadFile("fixtures/azuredevops-pr.json") + jsBytes, err := os.ReadFile("fixtures/azuredevops-pr.json") Ok(t, err) json := string(jsBytes) @@ -516,7 +517,7 @@ func TestAzureDevopsClient_PullIsApproved(t *testing.T) { func TestAzureDevopsClient_GetPullRequest(t *testing.T) { // Use a real Azure DevOps json response and edit the mergeable_state field. - jsBytes, err := ioutil.ReadFile("fixtures/azuredevops-pr.json") + jsBytes, err := os.ReadFile("fixtures/azuredevops-pr.json") Ok(t, err) response := string(jsBytes) diff --git a/server/events/vcs/bitbucketcloud/client.go b/server/events/vcs/bitbucketcloud/client.go index 979fcdc560..38dfa56a6b 100644 --- a/server/events/vcs/bitbucketcloud/client.go +++ b/server/events/vcs/bitbucketcloud/client.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "github.com/pkg/errors" @@ -236,10 +235,10 @@ func (b *Client) makeRequest(method string, path string, reqBody io.Reader) ([]b requestStr := fmt.Sprintf("%s %s", method, path) if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated { - respBody, _ := ioutil.ReadAll(resp.Body) + respBody, _ := io.ReadAll(resp.Body) return nil, fmt.Errorf("making request %q unexpected status code: %d, body: %s", requestStr, resp.StatusCode, string(respBody)) } - respBody, err := ioutil.ReadAll(resp.Body) + respBody, err := io.ReadAll(resp.Body) if err != nil { return nil, errors.Wrapf(err, "reading response from request %q", requestStr) } diff --git a/server/events/vcs/bitbucketcloud/client_test.go b/server/events/vcs/bitbucketcloud/client_test.go index b14c54894c..54e5179be8 100644 --- a/server/events/vcs/bitbucketcloud/client_test.go +++ b/server/events/vcs/bitbucketcloud/client_test.go @@ -2,9 +2,9 @@ package bitbucketcloud_test import ( "fmt" - "io/ioutil" "net/http" "net/http/httptest" + "os" "path/filepath" "testing" @@ -181,7 +181,7 @@ func TestClient_PullIsApproved(t *testing.T) { for _, c := range cases { t.Run(c.description, func(t *testing.T) { - json, err := ioutil.ReadFile(filepath.Join("testdata", c.testdata)) + json, err := os.ReadFile(filepath.Join("testdata", c.testdata)) Ok(t, err) testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.RequestURI { diff --git a/server/events/vcs/bitbucketserver/client.go b/server/events/vcs/bitbucketserver/client.go index 2a0e67e8f8..38a8acac14 100644 --- a/server/events/vcs/bitbucketserver/client.go +++ b/server/events/vcs/bitbucketserver/client.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "net/url" "regexp" @@ -324,10 +323,10 @@ func (b *Client) makeRequest(method string, path string, reqBody io.Reader) ([]b requestStr := fmt.Sprintf("%s %s", method, path) if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated && resp.StatusCode != 204 { - respBody, _ := ioutil.ReadAll(resp.Body) + respBody, _ := io.ReadAll(resp.Body) return nil, fmt.Errorf("making request %q unexpected status code: %d, body: %s", requestStr, resp.StatusCode, string(respBody)) } - respBody, err := ioutil.ReadAll(resp.Body) + respBody, err := io.ReadAll(resp.Body) if err != nil { return nil, errors.Wrapf(err, "reading response from request %q", requestStr) } diff --git a/server/events/vcs/bitbucketserver/client_test.go b/server/events/vcs/bitbucketserver/client_test.go index 2443e5f80e..73aa8b0962 100644 --- a/server/events/vcs/bitbucketserver/client_test.go +++ b/server/events/vcs/bitbucketserver/client_test.go @@ -3,9 +3,10 @@ package bitbucketserver_test import ( "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" + "os" "path/filepath" "strings" "testing" @@ -138,7 +139,7 @@ func TestClient_GetModifiedFilesPagination(t *testing.T) { // Test that we use the correct version parameter in our call to merge the pull // request. func TestClient_MergePull(t *testing.T) { - pullRequest, err := ioutil.ReadFile(filepath.Join("testdata", "pull-request.json")) + pullRequest, err := os.ReadFile(filepath.Join("testdata", "pull-request.json")) Ok(t, err) testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.RequestURI { @@ -187,7 +188,7 @@ func TestClient_MergePull(t *testing.T) { // Test that we delete the source branch in our call to merge the pull // request. func TestClient_MergePullDeleteSourceBranch(t *testing.T) { - pullRequest, err := ioutil.ReadFile(filepath.Join("testdata", "pull-request.json")) + pullRequest, err := os.ReadFile(filepath.Join("testdata", "pull-request.json")) Ok(t, err) testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.RequestURI { @@ -201,7 +202,7 @@ func TestClient_MergePullDeleteSourceBranch(t *testing.T) { case "/rest/branch-utils/1.0/projects/ow/repos/repo/branches": Equals(t, "DELETE", r.Method) defer r.Body.Close() - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) Ok(t, err) var payload bitbucketserver.DeleteSourceBranch err = json.Unmarshal(b, &payload) diff --git a/server/events/vcs/github_client_test.go b/server/events/vcs/github_client_test.go index 9d90e268be..bb4f55703e 100644 --- a/server/events/vcs/github_client_test.go +++ b/server/events/vcs/github_client_test.go @@ -4,10 +4,11 @@ import ( "crypto/tls" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "net/url" + "os" "strings" "testing" @@ -169,7 +170,7 @@ func TestGithubClient_PaginatesComments(t *testing.T) { switch r.Method + " " + r.RequestURI { case "POST /api/graphql": defer r.Body.Close() // nolint: errcheck - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) if err != nil { t.Errorf("read body error: %v", err) http.Error(w, "server error", http.StatusInternalServerError) @@ -272,7 +273,7 @@ func TestGithubClient_HideOldComments(t *testing.T) { return } defer r.Body.Close() // nolint: errcheck - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) if err != nil { t.Errorf("read body error: %v", err) http.Error(w, "server error", http.StatusInternalServerError) @@ -350,7 +351,7 @@ func TestGithubClient_UpdateStatus(t *testing.T) { http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.RequestURI { case "/api/v3/repos/owner/repo/statuses/": - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) Ok(t, err) exp := fmt.Sprintf(`{"state":"%s","target_url":"https://google.com","description":"description","context":"src"}%s`, c.expState, "\n") Equals(t, exp, string(body)) @@ -516,7 +517,7 @@ func TestGithubClient_PullIsMergeable(t *testing.T) { } // Use a real GitHub json response and edit the mergeable_state field. - jsBytes, err := ioutil.ReadFile("fixtures/github-pull-request.json") + jsBytes, err := os.ReadFile("fixtures/github-pull-request.json") Ok(t, err) json := string(jsBytes) @@ -590,7 +591,7 @@ func TestGithubClient_MergePullHandlesError(t *testing.T) { }, } - jsBytes, err := ioutil.ReadFile("fixtures/github-repo.json") + jsBytes, err := os.ReadFile("fixtures/github-repo.json") Ok(t, err) for _, c := range cases { @@ -602,7 +603,7 @@ func TestGithubClient_MergePullHandlesError(t *testing.T) { w.Write(jsBytes) // nolint: errcheck return case "/api/v3/repos/owner/repo/pulls/1/merge": - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) Ok(t, err) exp := "{\"merge_method\":\"merge\"}\n" Equals(t, exp, string(body)) @@ -700,7 +701,7 @@ func TestGithubClient_MergePullCorrectMethod(t *testing.T) { t.Run(name, func(t *testing.T) { // Modify response. - jsBytes, err := ioutil.ReadFile("fixtures/github-repo.json") + jsBytes, err := os.ReadFile("fixtures/github-repo.json") Ok(t, err) resp := string(jsBytes) resp = strings.Replace(resp, @@ -723,7 +724,7 @@ func TestGithubClient_MergePullCorrectMethod(t *testing.T) { w.Write([]byte(resp)) // nolint: errcheck return case "/api/v3/repos/runatlantis/atlantis/pulls/1/merge": - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) Ok(t, err) defer r.Body.Close() // nolint: errcheck type bodyJSON struct { @@ -806,7 +807,7 @@ func TestGithubClient_SplitComments(t *testing.T) { switch r.Method + " " + r.RequestURI { case "POST /api/v3/repos/runatlantis/atlantis/issues/1/comments": defer r.Body.Close() // nolint: errcheck - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) if err != nil { t.Errorf("read body error: %v", err) http.Error(w, "server error", http.StatusInternalServerError) diff --git a/server/events/vcs/gitlab_client_test.go b/server/events/vcs/gitlab_client_test.go index 9fdc29e0af..ceb393293a 100644 --- a/server/events/vcs/gitlab_client_test.go +++ b/server/events/vcs/gitlab_client_test.go @@ -2,7 +2,7 @@ package vcs import ( "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -210,7 +210,7 @@ func TestGitlabClient_UpdateStatus(t *testing.T) { case "/api/v4/projects/runatlantis%2Fatlantis/statuses/sha": gotRequest = true - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) Ok(t, err) exp := fmt.Sprintf(`{"state":"%s","context":"src","target_url":"https://google.com","description":"description"}`, c.expState) Equals(t, exp, string(body)) diff --git a/server/events/yaml/parser_validator.go b/server/events/yaml/parser_validator.go index d21b221ccd..00f4592f36 100644 --- a/server/events/yaml/parser_validator.go +++ b/server/events/yaml/parser_validator.go @@ -3,7 +3,6 @@ package yaml import ( "encoding/json" "fmt" - "io/ioutil" "os" "path/filepath" "strings" @@ -46,7 +45,7 @@ func (p *ParserValidator) HasRepoCfg(absRepoDir string) (bool, error) { // If there was no config file, it will return an os.IsNotExist(error). func (p *ParserValidator) ParseRepoCfg(absRepoDir string, globalCfg valid.GlobalCfg, repoID string) (valid.RepoCfg, error) { configFile := p.repoCfgPath(absRepoDir, AtlantisYAMLFilename) - configData, err := ioutil.ReadFile(configFile) // nolint: gosec + configData, err := os.ReadFile(configFile) // nolint: gosec if err != nil { if !os.IsNotExist(err) { @@ -94,7 +93,7 @@ func (p *ParserValidator) ParseRepoCfgData(repoCfgData []byte, globalCfg valid.G // configFile. defaultCfg will be merged into the parsed config. // If there is no file at configFile it will return an error. func (p *ParserValidator) ParseGlobalCfg(configFile string, defaultCfg valid.GlobalCfg) (valid.GlobalCfg, error) { - configData, err := ioutil.ReadFile(configFile) // nolint: gosec + configData, err := os.ReadFile(configFile) // nolint: gosec if err != nil { return valid.GlobalCfg{}, errors.Wrapf(err, "unable to read %s file", configFile) } diff --git a/server/events/yaml/parser_validator_test.go b/server/events/yaml/parser_validator_test.go index a722585e07..a58db826ef 100644 --- a/server/events/yaml/parser_validator_test.go +++ b/server/events/yaml/parser_validator_test.go @@ -2,7 +2,6 @@ package yaml_test import ( "fmt" - "io/ioutil" "os" "path/filepath" "regexp" @@ -68,7 +67,7 @@ func TestParseRepoCfg_FileDoesNotExist(t *testing.T) { func TestParseRepoCfg_BadPermissions(t *testing.T) { tmpDir, cleanup := TempDir(t) defer cleanup() - err := ioutil.WriteFile(filepath.Join(tmpDir, "atlantis.yaml"), nil, 0000) + err := os.WriteFile(filepath.Join(tmpDir, "atlantis.yaml"), nil, 0000) Ok(t, err) r := yaml.ParserValidator{} @@ -103,7 +102,7 @@ func TestParseCfgs_InvalidYAML(t *testing.T) { for _, c := range cases { t.Run(c.description, func(t *testing.T) { confPath := filepath.Join(tmpDir, "atlantis.yaml") - err := ioutil.WriteFile(confPath, []byte(c.input), 0600) + err := os.WriteFile(confPath, []byte(c.input), 0600) Ok(t, err) r := yaml.ParserValidator{} _, err = r.ParseRepoCfg(tmpDir, globalCfg, "") @@ -1068,7 +1067,7 @@ workflows: for _, c := range cases { t.Run(c.description, func(t *testing.T) { - err := ioutil.WriteFile(filepath.Join(tmpDir, "atlantis.yaml"), []byte(c.input), 0600) + err := os.WriteFile(filepath.Join(tmpDir, "atlantis.yaml"), []byte(c.input), 0600) Ok(t, err) r := yaml.ParserValidator{} @@ -1096,7 +1095,7 @@ projects: workflow: custom workflows: custom: ~` - err := ioutil.WriteFile(filepath.Join(tmpDir, "atlantis.yaml"), []byte(repoCfg), 0600) + err := os.WriteFile(filepath.Join(tmpDir, "atlantis.yaml"), []byte(repoCfg), 0600) Ok(t, err) r := yaml.ParserValidator{} @@ -1474,7 +1473,7 @@ workflows: tmp, cleanup := TempDir(t) defer cleanup() path := filepath.Join(tmp, "conf.yaml") - Ok(t, ioutil.WriteFile(path, []byte(c.input), 0600)) + Ok(t, os.WriteFile(path, []byte(c.input), 0600)) globalCfgArgs := valid.GlobalCfgArgs{ AllowRepoCfg: false, @@ -1735,8 +1734,8 @@ func TestParseRepoCfg_V2ShellParsing(t *testing.T) { apply: steps: - run: %s`, c.in, c.in) - Ok(t, ioutil.WriteFile(v2Path, []byte("version: 2\n"+cfg), 0600)) - Ok(t, ioutil.WriteFile(v3Path, []byte("version: 3\n"+cfg), 0600)) + Ok(t, os.WriteFile(v2Path, []byte("version: 2\n"+cfg), 0600)) + Ok(t, os.WriteFile(v3Path, []byte("version: 3\n"+cfg), 0600)) p := &yaml.ParserValidator{} globalCfgArgs := valid.GlobalCfgArgs{ diff --git a/server/events/yaml/valid/global_cfg_test.go b/server/events/yaml/valid/global_cfg_test.go index f317a81015..d1570ac2ed 100644 --- a/server/events/yaml/valid/global_cfg_test.go +++ b/server/events/yaml/valid/global_cfg_test.go @@ -2,7 +2,7 @@ package valid_test import ( "fmt" - "io/ioutil" + "os" "path/filepath" "regexp" "testing" @@ -661,7 +661,7 @@ policies: var global valid.GlobalCfg if c.gCfg != "" { path := filepath.Join(tmp, "config.yaml") - Ok(t, ioutil.WriteFile(path, []byte(c.gCfg), 0600)) + Ok(t, os.WriteFile(path, []byte(c.gCfg), 0600)) var err error globalCfgArgs := valid.GlobalCfgArgs{ AllowRepoCfg: false, @@ -832,7 +832,7 @@ repos: var global valid.GlobalCfg if c.gCfg != "" { path := filepath.Join(tmp, "config.yaml") - Ok(t, ioutil.WriteFile(path, []byte(c.gCfg), 0600)) + Ok(t, os.WriteFile(path, []byte(c.gCfg), 0600)) var err error globalCfgArgs := valid.GlobalCfgArgs{ AllowRepoCfg: false, diff --git a/server/recovery/recovery.go b/server/recovery/recovery.go index aff293fcf0..1039ef7503 100644 --- a/server/recovery/recovery.go +++ b/server/recovery/recovery.go @@ -22,7 +22,7 @@ package recovery import ( "bytes" "fmt" - "io/ioutil" + "os" "runtime" ) @@ -48,7 +48,7 @@ func Stack(skip int) []byte { // Print this much at least. If we can't find the source, it won't show. fmt.Fprintf(buf, "%s:%d (0x%x)\n", file, line, pc) if file != lastFile { - data, err := ioutil.ReadFile(file) // nolint: gosec + data, err := os.ReadFile(file) // nolint: gosec if err != nil { continue } diff --git a/server/server.go b/server/server.go index dbf3992921..5519ed18a8 100644 --- a/server/server.go +++ b/server/server.go @@ -20,7 +20,6 @@ import ( "encoding/json" "flag" "fmt" - "io/ioutil" "log" "net/http" "net/url" @@ -158,7 +157,7 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) { Token: userConfig.GithubToken, } } else if userConfig.GithubAppID != 0 && userConfig.GithubAppKeyFile != "" { - privateKey, err := ioutil.ReadFile(userConfig.GithubAppKeyFile) + privateKey, err := os.ReadFile(userConfig.GithubAppKeyFile) if err != nil { return nil, err } diff --git a/server/server_test.go b/server/server_test.go index 3b62d35b3c..4ed72785a1 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -16,10 +16,11 @@ package server_test import ( "bytes" "errors" - "io/ioutil" + "io" "net/http" "net/http/httptest" "net/url" + "os" "testing" "time" @@ -36,7 +37,7 @@ import ( func TestNewServer(t *testing.T) { t.Log("Run through NewServer constructor") - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") Ok(t, err) _, err = server.NewServer(server.UserConfig{ DataDir: tmpDir, @@ -48,7 +49,7 @@ func TestNewServer(t *testing.T) { // todo: test what happens if we set different flags. The generated config should be different. func TestNewServer_InvalidAtlantisURL(t *testing.T) { - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") Ok(t, err) _, err = server.NewServer(server.UserConfig{ DataDir: tmpDir, @@ -138,7 +139,7 @@ func TestHealthz(t *testing.T) { w := httptest.NewRecorder() s.Healthz(w, req) Equals(t, http.StatusOK, w.Result().StatusCode) - body, _ := ioutil.ReadAll(w.Result().Body) + body, _ := io.ReadAll(w.Result().Body) Equals(t, "application/json", w.Result().Header["Content-Type"][0]) Equals(t, `{ diff --git a/testdrive/testdrive.go b/testdrive/testdrive.go index 0e0356fde0..8ad0d1f86c 100644 --- a/testdrive/testdrive.go +++ b/testdrive/testdrive.go @@ -18,7 +18,6 @@ package testdrive import ( "context" "fmt" - "io/ioutil" "os" "os/exec" "os/signal" @@ -173,11 +172,11 @@ tunnels: proto: http `, ngrokAPIURL, atlantisPort) - ngrokConfigFile, err := ioutil.TempFile("", "") + ngrokConfigFile, err := os.CreateTemp("", "") if err != nil { return errors.Wrap(err, "creating ngrok config file") } - err = ioutil.WriteFile(ngrokConfigFile.Name(), []byte(ngrokConfig), 0600) + err = os.WriteFile(ngrokConfigFile.Name(), []byte(ngrokConfig), 0600) if err != nil { return errors.Wrap(err, "writing ngrok config file") } @@ -211,7 +210,7 @@ tunnels: // Start atlantis server. colorstring.Println("=> starting atlantis server") s.Start() - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") if err != nil { return errors.Wrap(err, "creating a temporary data directory for Atlantis") } diff --git a/testdrive/utils.go b/testdrive/utils.go index 2edafec1bb..a64b2c0754 100644 --- a/testdrive/utils.go +++ b/testdrive/utils.go @@ -20,7 +20,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "os" "os/exec" @@ -123,7 +122,7 @@ func getTunnelAddr() (string, error) { var t tunnels - body, err := ioutil.ReadAll(response.Body) + body, err := io.ReadAll(response.Body) if err != nil { return "", errors.Wrap(err, "reading ngrok api") } diff --git a/testing/http.go b/testing/http.go index ba19b54084..c6623e10bf 100644 --- a/testing/http.go +++ b/testing/http.go @@ -1,7 +1,7 @@ package testing import ( - "io/ioutil" + "io" "net/http/httptest" "strings" "testing" @@ -9,7 +9,7 @@ import ( func ResponseContains(t *testing.T, r *httptest.ResponseRecorder, status int, bodySubstr string) { t.Helper() - body, err := ioutil.ReadAll(r.Result().Body) + body, err := io.ReadAll(r.Result().Body) Ok(t, err) Assert(t, status == r.Result().StatusCode, "exp %d got %d, body: %s", status, r.Result().StatusCode, string(body)) Assert(t, strings.Contains(string(body), bodySubstr), "exp %q to be contained in %q", bodySubstr, string(body)) diff --git a/testing/temp_files.go b/testing/temp_files.go index 6bab8f03ab..3ee8b062c4 100644 --- a/testing/temp_files.go +++ b/testing/temp_files.go @@ -1,7 +1,6 @@ package testing import ( - "io/ioutil" "os" "path/filepath" "testing" @@ -12,7 +11,7 @@ import ( // dir, cleanup := TempDir() // defer cleanup() func TempDir(t *testing.T) (string, func()) { - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") Ok(t, err) return tmpDir, func() { os.RemoveAll(tmpDir) // nolint: errcheck @@ -65,7 +64,7 @@ func dirStructureGo(t *testing.T, parentDir string, structure map[string]interfa dirStructureGo(t, subDir, dirContents) } else if fileContent, ok := val.(string); ok { // If val is a string then key is a file name and val is the file's content - err := ioutil.WriteFile(filepath.Join(parentDir, key), []byte(fileContent), 0600) + err := os.WriteFile(filepath.Join(parentDir, key), []byte(fileContent), 0600) Ok(t, err) } } From 070f5174e75190925109686b684c53907afbe6d9 Mon Sep 17 00:00:00 2001 From: Bea Hughes Date: Wed, 6 Oct 2021 21:41:37 -0700 Subject: [PATCH 53/53] chore: use golang-jwt/jwt to replace dgrijalva/jwt-go (#1845) * Migrate dgrijalva/jwt-go to golang-jwt/jwt/v4 dgrijalva's jwt is no longer maintained. The golang-jwt says it is a drop in replacement for v4. This also fixes CVE-2020-26160 which possibly won't be fixed in dgrijalva's version. * Update occurrences of bradleyfalzon/ghinstallation to v2 v2.0.3 pulls in golang-jwt/jwt over the now unmaintained dgrijalva/jwt-go. --- go.mod | 11 +++++++---- go.sum | 16 ++++++++++++---- server/events/vcs/fixtures/fixtures.go | 2 +- server/events/vcs/github_credentials.go | 2 +- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index 8e434588e5..04fbb7970b 100644 --- a/go.mod +++ b/go.mod @@ -16,11 +16,9 @@ require ( github.com/aws/aws-sdk-go v1.31.15 // indirect github.com/aymerick/douceur v0.2.0 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect - github.com/bradleyfalzon/ghinstallation v1.1.1 github.com/briandowns/spinner v0.0.0-20170614154858-48dbb65d7bd5 github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc - github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/docker/docker v0.0.0-20180620051407-e2593239d949 github.com/elazarl/go-bindata-assetfs v1.0.1 github.com/fatih/color v1.9.0 // indirect @@ -30,12 +28,13 @@ require ( github.com/go-playground/locales v0.12.1 // indirect github.com/go-playground/universal-translator v0.16.0 // indirect github.com/go-test/deep v1.0.7 + github.com/golang-jwt/jwt/v4 v4.1.0 github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/google/go-cmp v0.5.6 // indirect github.com/google/go-github/v29 v29.0.2 // indirect github.com/google/go-github/v31 v31.0.0 - github.com/google/go-querystring v1.0.0 // indirect + github.com/google/go-querystring v1.1.0 // indirect github.com/google/uuid v1.1.2-0.20200519141726-cb32006e483f // indirect github.com/googleapis/gax-go/v2 v2.1.0 // indirect github.com/gorilla/css v1.0.0 // indirect @@ -120,4 +119,8 @@ require ( gotest.tools v2.2.0+incompatible // indirect ) -require golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect +require ( + github.com/bradleyfalzon/ghinstallation/v2 v2.0.3 // indirect + github.com/google/go-github/v39 v39.1.0 // indirect + golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect +) diff --git a/go.sum b/go.sum index faf1a2d2d1..abffc15587 100644 --- a/go.sum +++ b/go.sum @@ -79,8 +79,8 @@ github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZx github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bradleyfalzon/ghinstallation v1.1.1 h1:pmBXkxgM1WeF8QYvDLT5kuQiHMcmf+X015GI0KM/E3I= -github.com/bradleyfalzon/ghinstallation v1.1.1/go.mod h1:vyCmHTciHx/uuyN82Zc3rXN3X2KTK8nUTCrTMwAhcug= +github.com/bradleyfalzon/ghinstallation/v2 v2.0.3 h1:ywF/8q+GVpvlsEuvRb1SGSDQDUxntW1d4kFu/9q/YAE= +github.com/bradleyfalzon/ghinstallation/v2 v2.0.3/go.mod h1:tlgi+JWCXnKFx/Y4WtnDbZEINo31N5bcvnCoqieefmk= github.com/briandowns/spinner v0.0.0-20170614154858-48dbb65d7bd5 h1:osZyZB7J4kE1tKLeaUjV6+uZVBfS835T0I/RxmwWw1w= github.com/briandowns/spinner v0.0.0-20170614154858-48dbb65d7bd5/go.mod h1:hw/JEQBIE+c/BLI4aKM8UU8v+ZqrD3h7HC27kKt8JQU= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= @@ -97,8 +97,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/docker/docker v0.0.0-20180620051407-e2593239d949 h1:La/qO5ApRpiO4c0wGWFs4YB/HdobJHArySoQZfXtaUQ= github.com/docker/docker v0.0.0-20180620051407-e2593239d949/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/elazarl/go-bindata-assetfs v1.0.1 h1:m0kkaHRKEu7tUIUFVwhGGGYClXvyl4RE03qmvRTNfbw= @@ -130,6 +128,9 @@ github.com/go-test/deep v1.0.7 h1:/VSMRlnY/JSyqxQUzQLKVMAskpY/NZKFA5j2P+0pP2M= github.com/go-test/deep v1.0.7/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= +github.com/golang-jwt/jwt/v4 v4.1.0 h1:XUgk2Ex5veyVFVeLm0xhusUTQybEbexJXrvPNOKkSY0= +github.com/golang-jwt/jwt/v4 v4.1.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -183,8 +184,13 @@ github.com/google/go-github/v29 v29.0.2 h1:opYN6Wc7DOz7Ku3Oh4l7prmkOMwEcQxpFtxdU github.com/google/go-github/v29 v29.0.2/go.mod h1:CHKiKKPHJ0REzfwc14QMklvtHwCveD0PxlMjLlzAM5E= github.com/google/go-github/v31 v31.0.0 h1:JJUxlP9lFK+ziXKimTCprajMApV1ecWD4NB6CCb0plo= github.com/google/go-github/v31 v31.0.0/go.mod h1:NQPZol8/1sMoWYGN2yaALIBytu17gAWfhbweiEed3pM= +github.com/google/go-github/v39 v39.0.0/go.mod h1:C1s8C5aCC9L+JXIYpJM5GYytdX52vC1bLvHEF1IhBrE= +github.com/google/go-github/v39 v39.1.0 h1:1vf4gM0D1e+Df2HMxaYC3+o9+Huj3ywGTtWc3VVYaDA= +github.com/google/go-github/v39 v39.1.0/go.mod h1:C1s8C5aCC9L+JXIYpJM5GYytdX52vC1bLvHEF1IhBrE= github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= +github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= +github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= @@ -466,6 +472,8 @@ golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/server/events/vcs/fixtures/fixtures.go b/server/events/vcs/fixtures/fixtures.go index 5bd935ba4a..75330cbe0c 100644 --- a/server/events/vcs/fixtures/fixtures.go +++ b/server/events/vcs/fixtures/fixtures.go @@ -21,7 +21,7 @@ import ( "strings" "testing" - "github.com/dgrijalva/jwt-go" + "github.com/golang-jwt/jwt/v4" "github.com/google/go-github/v31/github" "github.com/mcdafydd/go-azuredevops/azuredevops" ) diff --git a/server/events/vcs/github_credentials.go b/server/events/vcs/github_credentials.go index 5c27eadea8..d70376c14d 100644 --- a/server/events/vcs/github_credentials.go +++ b/server/events/vcs/github_credentials.go @@ -7,7 +7,7 @@ import ( "net/url" "strings" - "github.com/bradleyfalzon/ghinstallation" + "github.com/bradleyfalzon/ghinstallation/v2" "github.com/google/go-github/v31/github" "github.com/pkg/errors" )