mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-07-28 21:28:20 +00:00
lint: gofmt -w -s . (#2504)
Signed-off-by: Rui Chen <rui@chenrui.dev> Signed-off-by: Rui Chen <rui@chenrui.dev>
This commit is contained in:
@@ -11,8 +11,10 @@ import (
|
||||
// usageTmpl returns a cobra-compatible usage template that will be printed
|
||||
// during the help output.
|
||||
// This template prints help like:
|
||||
// --name=<value>
|
||||
// <description>
|
||||
//
|
||||
// --name=<value>
|
||||
// <description>
|
||||
//
|
||||
// We use it over the default template so that the output it easier to read.
|
||||
func usageTmpl(stringFlags map[string]stringFlag, intFlags map[string]intFlag, boolFlags map[string]boolFlag) string {
|
||||
var flagNames []string
|
||||
|
||||
4
main.go
4
main.go
@@ -3,7 +3,9 @@
|
||||
// Licensed under the Apache License, Version 2.0 (the License);
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an AS IS BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
@@ -1373,11 +1373,12 @@ func ensureRunning014(t *testing.T) {
|
||||
}
|
||||
|
||||
// versionRegex extracts the version from `terraform version` output.
|
||||
// Terraform v0.12.0-alpha4 (2c36829d3265661d8edbd5014de8090ea7e2a076)
|
||||
// => 0.12.0-alpha4
|
||||
//
|
||||
// Terraform v0.11.10
|
||||
// => 0.11.10
|
||||
// Terraform v0.12.0-alpha4 (2c36829d3265661d8edbd5014de8090ea7e2a076)
|
||||
// => 0.12.0-alpha4
|
||||
//
|
||||
// Terraform v0.11.10
|
||||
// => 0.11.10
|
||||
var versionRegex = regexp.MustCompile("Terraform v(.*?)(\\s.*)?\n")
|
||||
|
||||
var versionConftestRegex = regexp.MustCompile("Version: (.*?)(\\s.*)?\n")
|
||||
|
||||
@@ -28,19 +28,23 @@ const (
|
||||
|
||||
// Step represents a single action/command to perform. In YAML, it can be set as
|
||||
// 1. A single string for a built-in command:
|
||||
// - init
|
||||
// - plan
|
||||
// - policy_check
|
||||
// - init
|
||||
// - plan
|
||||
// - policy_check
|
||||
//
|
||||
// 2. A map for an env step with name and command or value
|
||||
// - env:
|
||||
// name: test
|
||||
// command: echo 312
|
||||
// value: value
|
||||
// - env:
|
||||
// name: test
|
||||
// command: echo 312
|
||||
// value: value
|
||||
//
|
||||
// 3. A map for a built-in command and extra_args:
|
||||
// - plan:
|
||||
// extra_args: [-var-file=staging.tfvars]
|
||||
// - plan:
|
||||
// extra_args: [-var-file=staging.tfvars]
|
||||
//
|
||||
// 4. A map for a custom run command:
|
||||
// - run: my custom command
|
||||
// - run: my custom command
|
||||
//
|
||||
// Here we parse step in the most generic fashion possible. See fields for more
|
||||
// details.
|
||||
type Step struct {
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
// WorkflowHook represents a single action/command to perform. In YAML,
|
||||
// it can be set as
|
||||
// A map for a custom run commands:
|
||||
// - run: my custom command
|
||||
// - run: my custom command
|
||||
type WorkflowHook struct {
|
||||
StringVal map[string]string
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
// Licensed under the Apache License, Version 2.0 (the License);
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an AS IS BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
@@ -69,8 +69,9 @@ func (c ConftestTestCommandArgs) build() ([]string, error) {
|
||||
return commandArgs, nil
|
||||
}
|
||||
|
||||
//go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_conftest_client.go SourceResolver
|
||||
// SourceResolver resolves the policy set to a local fs path
|
||||
//
|
||||
//go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_conftest_client.go SourceResolver
|
||||
type SourceResolver interface {
|
||||
Resolve(policySet valid.PolicySet) (string, error)
|
||||
}
|
||||
|
||||
@@ -50,8 +50,9 @@ type StatusUpdater interface {
|
||||
UpdateProject(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus, url string) error
|
||||
}
|
||||
|
||||
//go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_runner.go Runner
|
||||
// Runner mirrors events.StepRunner as a way to bring it into this package
|
||||
//
|
||||
//go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_runner.go Runner
|
||||
type Runner interface {
|
||||
Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
// Licensed under the Apache License, Version 2.0 (the License);
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an AS IS BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -90,11 +92,12 @@ type Downloader interface {
|
||||
}
|
||||
|
||||
// versionRegex extracts the version from `terraform version` output.
|
||||
// Terraform v0.12.0-alpha4 (2c36829d3265661d8edbd5014de8090ea7e2a076)
|
||||
// => 0.12.0-alpha4
|
||||
//
|
||||
// Terraform v0.11.10
|
||||
// => 0.11.10
|
||||
// Terraform v0.12.0-alpha4 (2c36829d3265661d8edbd5014de8090ea7e2a076)
|
||||
// => 0.12.0-alpha4
|
||||
//
|
||||
// Terraform v0.11.10
|
||||
// => 0.11.10
|
||||
var versionRegex = regexp.MustCompile("Terraform v(.*?)(\\s.*)?\n")
|
||||
|
||||
// NewClientWithDefaultVersion creates a new terraform client and pre-fetches the default version
|
||||
|
||||
@@ -96,12 +96,12 @@ type CommentParseResult struct {
|
||||
// Parse parses the comment as an Atlantis command.
|
||||
//
|
||||
// Valid commands contain:
|
||||
// - The initial "executable" name, 'run' or 'atlantis' or '@GithubUser'
|
||||
// where GithubUser is the API user Atlantis is running as.
|
||||
// - Then a command: 'plan', 'apply', 'unlock', 'version, 'approve_policies',
|
||||
// or 'help'.
|
||||
// - Then optional flags, then an optional separator '--' followed by optional
|
||||
// extra flags to be appended to the terraform plan/apply command.
|
||||
// - The initial "executable" name, 'run' or 'atlantis' or '@GithubUser'
|
||||
// where GithubUser is the API user Atlantis is running as.
|
||||
// - Then a command: 'plan', 'apply', 'unlock', 'version, 'approve_policies',
|
||||
// or 'help'.
|
||||
// - Then optional flags, then an optional separator '--' followed by optional
|
||||
// extra flags to be appended to the terraform plan/apply command.
|
||||
//
|
||||
// Examples:
|
||||
// - atlantis help
|
||||
@@ -112,7 +112,6 @@ type CommentParseResult struct {
|
||||
// - atlantis unlock
|
||||
// - atlantis version
|
||||
// - atlantis approve_policies
|
||||
//
|
||||
func (e *CommentParser) Parse(rawComment string, vcsHost models.VCSHostType) CommentParseResult {
|
||||
comment := strings.TrimSpace(rawComment)
|
||||
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
// Licensed under the Apache License, Version 2.0 (the License);
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an AS IS BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -68,7 +70,8 @@ func (r Repo) ID() string {
|
||||
// NewRepo constructs a Repo object. repoFullName is the owner/repo form,
|
||||
// cloneURL can be with or without .git at the end
|
||||
// ex. https://github.com/runatlantis/atlantis.git OR
|
||||
// https://github.com/runatlantis/atlantis
|
||||
//
|
||||
// https://github.com/runatlantis/atlantis
|
||||
func NewRepo(vcsHostType VCSHostType, repoFullName string, cloneURL string, vcsUser string, vcsToken string) (Repo, error) {
|
||||
if repoFullName == "" {
|
||||
return Repo{}, errors.New("repoFullName can't be empty")
|
||||
@@ -335,8 +338,9 @@ func NewVCSHostType(t string) (VCSHostType, error) {
|
||||
// name segments. If the repoFullName is malformed, may return empty
|
||||
// strings for owner or repo.
|
||||
// Ex. runatlantis/atlantis => (runatlantis, atlantis)
|
||||
// gitlab/subgroup/runatlantis/atlantis => (gitlab/subgroup/runatlantis, atlantis)
|
||||
// azuredevops/project/atlantis => (azuredevops/project, atlantis)
|
||||
//
|
||||
// gitlab/subgroup/runatlantis/atlantis => (gitlab/subgroup/runatlantis, atlantis)
|
||||
// azuredevops/project/atlantis => (azuredevops/project, atlantis)
|
||||
func SplitRepoFullName(repoFullName string) (owner string, repo string) {
|
||||
lastSlashIdx := strings.LastIndex(repoFullName, "/")
|
||||
if lastSlashIdx == -1 || lastSlashIdx == len(repoFullName)-1 {
|
||||
|
||||
@@ -362,8 +362,9 @@ func (g *AzureDevopsClient) MarkdownPullLink(pull models.PullRequest) (string, e
|
||||
// repoFullName format owner/project/repo.
|
||||
//
|
||||
// Ex. runatlantis/atlantis => (runatlantis, atlantis)
|
||||
// gitlab/subgroup/runatlantis/atlantis => (gitlab/subgroup/runatlantis, atlantis)
|
||||
// azuredevops/project/atlantis => (azuredevops, project, atlantis)
|
||||
//
|
||||
// gitlab/subgroup/runatlantis/atlantis => (gitlab/subgroup/runatlantis, atlantis)
|
||||
// azuredevops/project/atlantis => (azuredevops, project, atlantis)
|
||||
func SplitAzureDevopsRepoFullName(repoFullName string) (owner string, project string, repo string) {
|
||||
firstSlashIdx := strings.Index(repoFullName, "/")
|
||||
lastSlashIdx := strings.LastIndex(repoFullName, "/")
|
||||
|
||||
@@ -142,8 +142,6 @@ func (c *MockSlackClient_TokenIsSet_OngoingVerification) GetCapturedArguments()
|
||||
func (c *MockSlackClient_TokenIsSet_OngoingVerification) GetAllCapturedArguments() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
func (verifier *VerifierMockSlackClient) PostMessage(channel string, applyResult webhooks.ApplyResult) *MockSlackClient_PostMessage_OngoingVerification {
|
||||
params := []pegomock.Param{channel, applyResult}
|
||||
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "PostMessage", params, verifier.timeout)
|
||||
|
||||
@@ -79,7 +79,7 @@ type FileWorkspace struct {
|
||||
// path to the root of the cloned repo. It also returns
|
||||
// a boolean indicating if we should warn users that the branch we're
|
||||
// merging into has been updated since we cloned it.
|
||||
//If the repo already exists and is at
|
||||
// If the repo already exists and is at
|
||||
// the right commit it does nothing. This is to support running commands in
|
||||
// multiple dirs of the same repo without deleting existing plans.
|
||||
func (w *FileWorkspace) Clone(
|
||||
|
||||
@@ -179,7 +179,7 @@ func (p *AsyncProjectCommandOutputHandler) addChan(ch chan string, jobID string)
|
||||
p.receiverBuffersLock.Unlock()
|
||||
}
|
||||
|
||||
//Add log line to buffer and send to all current channels
|
||||
// Add log line to buffer and send to all current channels
|
||||
func (p *AsyncProjectCommandOutputHandler) writeLogLine(jobID string, line string) {
|
||||
p.receiverBuffersLock.Lock()
|
||||
for ch := range p.receiverBuffers[jobID] {
|
||||
@@ -205,7 +205,7 @@ func (p *AsyncProjectCommandOutputHandler) writeLogLine(jobID string, line strin
|
||||
p.projectOutputBuffersLock.Unlock()
|
||||
}
|
||||
|
||||
//Remove channel, so client no longer receives Terraform output
|
||||
// Remove channel, so client no longer receives Terraform output
|
||||
func (p *AsyncProjectCommandOutputHandler) Deregister(jobID string, ch chan string) {
|
||||
p.logger.Debug("Removing channel for %s", jobID)
|
||||
p.receiverBuffersLock.Lock()
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
// Licensed under the Apache License, Version 2.0 (the License);
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an AS IS BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
// Licensed under the Apache License, Version 2.0 (the License);
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an AS IS BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
@@ -355,11 +355,13 @@ var _bindata = map[string]func() (*asset, error){
|
||||
// directory embedded in the file by go-bindata.
|
||||
// For example if you run go-bindata on data/... and data contains the
|
||||
// following hierarchy:
|
||||
// data/
|
||||
// foo.txt
|
||||
// img/
|
||||
// a.png
|
||||
// b.png
|
||||
//
|
||||
// data/
|
||||
// foo.txt
|
||||
// img/
|
||||
// a.png
|
||||
// b.png
|
||||
//
|
||||
// then AssetDir("data") would return []string{"foo.txt", "img"}
|
||||
// AssetDir("data/img") would return []string{"a.png", "b.png"}
|
||||
// AssetDir("foo.txt") and AssetDir("notexist") would return an error
|
||||
@@ -392,22 +394,22 @@ type bintree struct {
|
||||
}
|
||||
|
||||
var _bintree = &bintree{nil, map[string]*bintree{
|
||||
"static": &bintree{nil, map[string]*bintree{
|
||||
"css": &bintree{nil, map[string]*bintree{
|
||||
"custom.css": &bintree{staticCssCustomCss, map[string]*bintree{}},
|
||||
"normalize.css": &bintree{staticCssNormalizeCss, map[string]*bintree{}},
|
||||
"skeleton.css": &bintree{staticCssSkeletonCss, map[string]*bintree{}},
|
||||
"xterm.css": &bintree{staticCssXtermCss, map[string]*bintree{}},
|
||||
"static": {nil, map[string]*bintree{
|
||||
"css": {nil, map[string]*bintree{
|
||||
"custom.css": {staticCssCustomCss, map[string]*bintree{}},
|
||||
"normalize.css": {staticCssNormalizeCss, map[string]*bintree{}},
|
||||
"skeleton.css": {staticCssSkeletonCss, map[string]*bintree{}},
|
||||
"xterm.css": {staticCssXtermCss, map[string]*bintree{}},
|
||||
}},
|
||||
"images": &bintree{nil, map[string]*bintree{
|
||||
"atlantis-icon.png": &bintree{staticImagesAtlantisIconPng, map[string]*bintree{}},
|
||||
"atlantis-icon_512.png": &bintree{staticImagesAtlantisIcon_512Png, map[string]*bintree{}},
|
||||
"images": {nil, map[string]*bintree{
|
||||
"atlantis-icon.png": {staticImagesAtlantisIconPng, map[string]*bintree{}},
|
||||
"atlantis-icon_512.png": {staticImagesAtlantisIcon_512Png, map[string]*bintree{}},
|
||||
}},
|
||||
"js": &bintree{nil, map[string]*bintree{
|
||||
"jquery-3.5.1.min.js": &bintree{staticJsJquery351MinJs, map[string]*bintree{}},
|
||||
"xterm-4.9.0.js": &bintree{staticJsXterm490Js, map[string]*bintree{}},
|
||||
"xterm-addon-attach-0.6.0.js": &bintree{staticJsXtermAddonAttach060Js, map[string]*bintree{}},
|
||||
"xterm-addon-fit-0.4.0.js": &bintree{staticJsXtermAddonFit040Js, map[string]*bintree{}},
|
||||
"js": {nil, map[string]*bintree{
|
||||
"jquery-3.5.1.min.js": {staticJsJquery351MinJs, map[string]*bintree{}},
|
||||
"xterm-4.9.0.js": {staticJsXterm490Js, map[string]*bintree{}},
|
||||
"xterm-addon-attach-0.6.0.js": {staticJsXtermAddonAttach060Js, map[string]*bintree{}},
|
||||
"xterm-addon-fit-0.4.0.js": {staticJsXtermAddonFit040Js, map[string]*bintree{}},
|
||||
}},
|
||||
}},
|
||||
}}
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
// Licensed under the Apache License, Version 2.0 (the License);
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an AS IS BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
@@ -8,8 +8,9 @@ import (
|
||||
|
||||
// TempDir creates a temporary directory and returns its path along
|
||||
// with a cleanup function to be called via defer, ex:
|
||||
// dir, cleanup := TempDir()
|
||||
// defer cleanup()
|
||||
//
|
||||
// dir, cleanup := TempDir()
|
||||
// defer cleanup()
|
||||
func TempDir(t *testing.T) (string, func()) {
|
||||
tmpDir, err := os.MkdirTemp("", "")
|
||||
Ok(t, err)
|
||||
@@ -25,23 +26,23 @@ func TempDir(t *testing.T) (string, func()) {
|
||||
// It returns the path to the temp directory containing the defined
|
||||
// structure and a cleanup function to delete the directory.
|
||||
// Example usage:
|
||||
// versionConfig := `
|
||||
// terraform {
|
||||
// required_version = "= 0.12.8"
|
||||
// }
|
||||
// `
|
||||
// tmpDir, cleanup := DirStructure(t, map[string]interface{}{
|
||||
// "pulldir": map[string]interface{}{
|
||||
// "project1": map[string]interface{}{
|
||||
// "main.tf": nil,
|
||||
// },
|
||||
// "project2": map[string]interface{}{,
|
||||
// "main.tf": versionConfig,
|
||||
// },
|
||||
// },
|
||||
// })
|
||||
// defer cleanup()
|
||||
//
|
||||
// versionConfig := `
|
||||
// terraform {
|
||||
// required_version = "= 0.12.8"
|
||||
// }
|
||||
// `
|
||||
// tmpDir, cleanup := DirStructure(t, map[string]interface{}{
|
||||
// "pulldir": map[string]interface{}{
|
||||
// "project1": map[string]interface{}{
|
||||
// "main.tf": nil,
|
||||
// },
|
||||
// "project2": map[string]interface{}{,
|
||||
// "main.tf": versionConfig,
|
||||
// },
|
||||
// },
|
||||
// })
|
||||
// defer cleanup()
|
||||
func DirStructure(t *testing.T, structure map[string]interface{}) (string, func()) {
|
||||
tmpDir, cleanup := TempDir(t)
|
||||
dirStructureGo(t, tmpDir, structure)
|
||||
|
||||
Reference in New Issue
Block a user