cli/commands/ci/lint/lint.go

117 lines
2.7 KiB
Go
Raw Normal View History

Isolate commands into separate sub-packages (#229) * refactor: organize commands into separate subfolders * Format code with gofmt This commit fixes the style issues introduced in d1f70d5 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/1ce57d1c-4f1e-48c2-a4d8-00c1bce7fb49/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in ca0bff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/11379011-98c6-43ea-8baa-4fefa9b775e4/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in 00e5936 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/c912f945-acf3-48d2-a550-0895c0153df0/ * Done with sub-packaging 🔥 * 🔥 tests * Format code with gofmt This commit fixes the style issues introduced in 56a8ff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/24498865-4980-479f-90c7-7ddd228c2bb4/ * fix bug risks * fix tests * fix tests * Format code with gofmt This commit fixes the style issues introduced in c947d02 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/cb2ac46a-f857-40d5-8508-eacc253b3614/ * Format code with gofmt This commit fixes the style issues introduced in 902ff7b according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f60ba0d6-94d3-47c0-ae27-568a5cc5d9e5/ * fix tests * fix tests * 🔥 gookit/color * Format code with gofmt This commit fixes the style issues introduced in 5a129ea according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/8f1c8327-f5c6-4ff5-97d2-3c8a23f0a1e2/ * Autofix issues in 1 files Resolved issues in the following files via DeepSource Autofix: 1. commands/cmdtest/helper.go * add tests for MR * Format code with gofmt This commit fixes the style issues introduced in 758af28 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/d55a4867-aa23-4202-b2cc-a7ceafbaa53e/ * migrate old config to new config * fix bug risks * Format code with gofmt This commit fixes the style issues introduced in 0ea8eb2 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f90cf664-8396-4b78-814d-3167ce898164/ * refactoring Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2020-09-29 05:55:34 +00:00
package lint
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
2022-09-19 20:23:45 +00:00
"gitlab.com/gitlab-org/cli/api"
"gitlab.com/gitlab-org/cli/commands/cmdutils"
"gitlab.com/gitlab-org/cli/pkg/git"
Isolate commands into separate sub-packages (#229) * refactor: organize commands into separate subfolders * Format code with gofmt This commit fixes the style issues introduced in d1f70d5 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/1ce57d1c-4f1e-48c2-a4d8-00c1bce7fb49/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in ca0bff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/11379011-98c6-43ea-8baa-4fefa9b775e4/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in 00e5936 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/c912f945-acf3-48d2-a550-0895c0153df0/ * Done with sub-packaging 🔥 * 🔥 tests * Format code with gofmt This commit fixes the style issues introduced in 56a8ff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/24498865-4980-479f-90c7-7ddd228c2bb4/ * fix bug risks * fix tests * fix tests * Format code with gofmt This commit fixes the style issues introduced in c947d02 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/cb2ac46a-f857-40d5-8508-eacc253b3614/ * Format code with gofmt This commit fixes the style issues introduced in 902ff7b according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f60ba0d6-94d3-47c0-ae27-568a5cc5d9e5/ * fix tests * fix tests * 🔥 gookit/color * Format code with gofmt This commit fixes the style issues introduced in 5a129ea according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/8f1c8327-f5c6-4ff5-97d2-3c8a23f0a1e2/ * Autofix issues in 1 files Resolved issues in the following files via DeepSource Autofix: 1. commands/cmdtest/helper.go * add tests for MR * Format code with gofmt This commit fixes the style issues introduced in 758af28 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/d55a4867-aa23-4202-b2cc-a7ceafbaa53e/ * migrate old config to new config * fix bug risks * Format code with gofmt This commit fixes the style issues introduced in 0ea8eb2 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f90cf664-8396-4b78-814d-3167ce898164/ * refactoring Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2020-09-29 05:55:34 +00:00
"github.com/MakeNowJust/heredoc"
"github.com/spf13/cobra"
)
var (
ref string
dryRun bool
includeJobs bool
)
Isolate commands into separate sub-packages (#229) * refactor: organize commands into separate subfolders * Format code with gofmt This commit fixes the style issues introduced in d1f70d5 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/1ce57d1c-4f1e-48c2-a4d8-00c1bce7fb49/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in ca0bff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/11379011-98c6-43ea-8baa-4fefa9b775e4/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in 00e5936 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/c912f945-acf3-48d2-a550-0895c0153df0/ * Done with sub-packaging 🔥 * 🔥 tests * Format code with gofmt This commit fixes the style issues introduced in 56a8ff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/24498865-4980-479f-90c7-7ddd228c2bb4/ * fix bug risks * fix tests * fix tests * Format code with gofmt This commit fixes the style issues introduced in c947d02 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/cb2ac46a-f857-40d5-8508-eacc253b3614/ * Format code with gofmt This commit fixes the style issues introduced in 902ff7b according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f60ba0d6-94d3-47c0-ae27-568a5cc5d9e5/ * fix tests * fix tests * 🔥 gookit/color * Format code with gofmt This commit fixes the style issues introduced in 5a129ea according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/8f1c8327-f5c6-4ff5-97d2-3c8a23f0a1e2/ * Autofix issues in 1 files Resolved issues in the following files via DeepSource Autofix: 1. commands/cmdtest/helper.go * add tests for MR * Format code with gofmt This commit fixes the style issues introduced in 758af28 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/d55a4867-aa23-4202-b2cc-a7ceafbaa53e/ * migrate old config to new config * fix bug risks * Format code with gofmt This commit fixes the style issues introduced in 0ea8eb2 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f90cf664-8396-4b78-814d-3167ce898164/ * refactoring Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2020-09-29 05:55:34 +00:00
func NewCmdLint(f *cmdutils.Factory) *cobra.Command {
pipelineCILintCmd := &cobra.Command{
Isolate commands into separate sub-packages (#229) * refactor: organize commands into separate subfolders * Format code with gofmt This commit fixes the style issues introduced in d1f70d5 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/1ce57d1c-4f1e-48c2-a4d8-00c1bce7fb49/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in ca0bff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/11379011-98c6-43ea-8baa-4fefa9b775e4/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in 00e5936 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/c912f945-acf3-48d2-a550-0895c0153df0/ * Done with sub-packaging 🔥 * 🔥 tests * Format code with gofmt This commit fixes the style issues introduced in 56a8ff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/24498865-4980-479f-90c7-7ddd228c2bb4/ * fix bug risks * fix tests * fix tests * Format code with gofmt This commit fixes the style issues introduced in c947d02 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/cb2ac46a-f857-40d5-8508-eacc253b3614/ * Format code with gofmt This commit fixes the style issues introduced in 902ff7b according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f60ba0d6-94d3-47c0-ae27-568a5cc5d9e5/ * fix tests * fix tests * 🔥 gookit/color * Format code with gofmt This commit fixes the style issues introduced in 5a129ea according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/8f1c8327-f5c6-4ff5-97d2-3c8a23f0a1e2/ * Autofix issues in 1 files Resolved issues in the following files via DeepSource Autofix: 1. commands/cmdtest/helper.go * add tests for MR * Format code with gofmt This commit fixes the style issues introduced in 758af28 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/d55a4867-aa23-4202-b2cc-a7ceafbaa53e/ * migrate old config to new config * fix bug risks * Format code with gofmt This commit fixes the style issues introduced in 0ea8eb2 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f90cf664-8396-4b78-814d-3167ce898164/ * refactoring Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2020-09-29 05:55:34 +00:00
Use: "lint",
Short: "Checks if your `.gitlab-ci.yml` file is valid.",
2020-12-21 15:59:47 +00:00
Args: cobra.MaximumNArgs(1),
Isolate commands into separate sub-packages (#229) * refactor: organize commands into separate subfolders * Format code with gofmt This commit fixes the style issues introduced in d1f70d5 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/1ce57d1c-4f1e-48c2-a4d8-00c1bce7fb49/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in ca0bff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/11379011-98c6-43ea-8baa-4fefa9b775e4/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in 00e5936 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/c912f945-acf3-48d2-a550-0895c0153df0/ * Done with sub-packaging 🔥 * 🔥 tests * Format code with gofmt This commit fixes the style issues introduced in 56a8ff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/24498865-4980-479f-90c7-7ddd228c2bb4/ * fix bug risks * fix tests * fix tests * Format code with gofmt This commit fixes the style issues introduced in c947d02 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/cb2ac46a-f857-40d5-8508-eacc253b3614/ * Format code with gofmt This commit fixes the style issues introduced in 902ff7b according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f60ba0d6-94d3-47c0-ae27-568a5cc5d9e5/ * fix tests * fix tests * 🔥 gookit/color * Format code with gofmt This commit fixes the style issues introduced in 5a129ea according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/8f1c8327-f5c6-4ff5-97d2-3c8a23f0a1e2/ * Autofix issues in 1 files Resolved issues in the following files via DeepSource Autofix: 1. commands/cmdtest/helper.go * add tests for MR * Format code with gofmt This commit fixes the style issues introduced in 758af28 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/d55a4867-aa23-4202-b2cc-a7ceafbaa53e/ * migrate old config to new config * fix bug risks * Format code with gofmt This commit fixes the style issues introduced in 0ea8eb2 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f90cf664-8396-4b78-814d-3167ce898164/ * refactoring Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2020-09-29 05:55:34 +00:00
Example: heredoc.Doc(`
$ glab ci lint
# Uses .gitlab-ci.yml in the current directory
2020-12-21 15:59:47 +00:00
2020-12-21 12:21:59 +00:00
$ glab ci lint .gitlab-ci.yml
2020-12-21 15:59:47 +00:00
2020-12-21 12:21:59 +00:00
$ glab ci lint path/to/.gitlab-ci.yml
Isolate commands into separate sub-packages (#229) * refactor: organize commands into separate subfolders * Format code with gofmt This commit fixes the style issues introduced in d1f70d5 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/1ce57d1c-4f1e-48c2-a4d8-00c1bce7fb49/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in ca0bff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/11379011-98c6-43ea-8baa-4fefa9b775e4/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in 00e5936 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/c912f945-acf3-48d2-a550-0895c0153df0/ * Done with sub-packaging 🔥 * 🔥 tests * Format code with gofmt This commit fixes the style issues introduced in 56a8ff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/24498865-4980-479f-90c7-7ddd228c2bb4/ * fix bug risks * fix tests * fix tests * Format code with gofmt This commit fixes the style issues introduced in c947d02 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/cb2ac46a-f857-40d5-8508-eacc253b3614/ * Format code with gofmt This commit fixes the style issues introduced in 902ff7b according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f60ba0d6-94d3-47c0-ae27-568a5cc5d9e5/ * fix tests * fix tests * 🔥 gookit/color * Format code with gofmt This commit fixes the style issues introduced in 5a129ea according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/8f1c8327-f5c6-4ff5-97d2-3c8a23f0a1e2/ * Autofix issues in 1 files Resolved issues in the following files via DeepSource Autofix: 1. commands/cmdtest/helper.go * add tests for MR * Format code with gofmt This commit fixes the style issues introduced in 758af28 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/d55a4867-aa23-4202-b2cc-a7ceafbaa53e/ * migrate old config to new config * fix bug risks * Format code with gofmt This commit fixes the style issues introduced in 0ea8eb2 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f90cf664-8396-4b78-814d-3167ce898164/ * refactoring Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2020-09-29 05:55:34 +00:00
`),
RunE: func(cmd *cobra.Command, args []string) error {
path := ".gitlab-ci.yml"
if len(args) == 1 {
path = args[0]
}
2020-12-21 15:59:47 +00:00
return lintRun(f, path)
},
}
2020-10-20 20:04:23 +00:00
pipelineCILintCmd.Flags().BoolVarP(&dryRun, "dry-run", "", false, "Run pipeline creation simulation.")
pipelineCILintCmd.Flags().BoolVarP(&includeJobs, "include-jobs", "", false, "The response should include the list of jobs that would exist in a static check or pipeline simulation.")
pipelineCILintCmd.Flags().StringVar(&ref, "ref", "", "When dry-run is true, sets the branch or tag context for validating the CI/CD YAML configuration.")
2020-12-21 15:59:47 +00:00
return pipelineCILintCmd
}
Isolate commands into separate sub-packages (#229) * refactor: organize commands into separate subfolders * Format code with gofmt This commit fixes the style issues introduced in d1f70d5 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/1ce57d1c-4f1e-48c2-a4d8-00c1bce7fb49/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in ca0bff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/11379011-98c6-43ea-8baa-4fefa9b775e4/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in 00e5936 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/c912f945-acf3-48d2-a550-0895c0153df0/ * Done with sub-packaging 🔥 * 🔥 tests * Format code with gofmt This commit fixes the style issues introduced in 56a8ff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/24498865-4980-479f-90c7-7ddd228c2bb4/ * fix bug risks * fix tests * fix tests * Format code with gofmt This commit fixes the style issues introduced in c947d02 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/cb2ac46a-f857-40d5-8508-eacc253b3614/ * Format code with gofmt This commit fixes the style issues introduced in 902ff7b according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f60ba0d6-94d3-47c0-ae27-568a5cc5d9e5/ * fix tests * fix tests * 🔥 gookit/color * Format code with gofmt This commit fixes the style issues introduced in 5a129ea according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/8f1c8327-f5c6-4ff5-97d2-3c8a23f0a1e2/ * Autofix issues in 1 files Resolved issues in the following files via DeepSource Autofix: 1. commands/cmdtest/helper.go * add tests for MR * Format code with gofmt This commit fixes the style issues introduced in 758af28 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/d55a4867-aa23-4202-b2cc-a7ceafbaa53e/ * migrate old config to new config * fix bug risks * Format code with gofmt This commit fixes the style issues introduced in 0ea8eb2 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f90cf664-8396-4b78-814d-3167ce898164/ * refactoring Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2020-09-29 05:55:34 +00:00
2020-12-21 15:59:47 +00:00
func lintRun(f *cmdutils.Factory, path string) error {
var err error
out := f.IO.StdOut
2021-01-29 00:56:45 +00:00
c := f.IO.Color()
Isolate commands into separate sub-packages (#229) * refactor: organize commands into separate subfolders * Format code with gofmt This commit fixes the style issues introduced in d1f70d5 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/1ce57d1c-4f1e-48c2-a4d8-00c1bce7fb49/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in ca0bff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/11379011-98c6-43ea-8baa-4fefa9b775e4/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in 00e5936 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/c912f945-acf3-48d2-a550-0895c0153df0/ * Done with sub-packaging 🔥 * 🔥 tests * Format code with gofmt This commit fixes the style issues introduced in 56a8ff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/24498865-4980-479f-90c7-7ddd228c2bb4/ * fix bug risks * fix tests * fix tests * Format code with gofmt This commit fixes the style issues introduced in c947d02 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/cb2ac46a-f857-40d5-8508-eacc253b3614/ * Format code with gofmt This commit fixes the style issues introduced in 902ff7b according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f60ba0d6-94d3-47c0-ae27-568a5cc5d9e5/ * fix tests * fix tests * 🔥 gookit/color * Format code with gofmt This commit fixes the style issues introduced in 5a129ea according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/8f1c8327-f5c6-4ff5-97d2-3c8a23f0a1e2/ * Autofix issues in 1 files Resolved issues in the following files via DeepSource Autofix: 1. commands/cmdtest/helper.go * add tests for MR * Format code with gofmt This commit fixes the style issues introduced in 758af28 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/d55a4867-aa23-4202-b2cc-a7ceafbaa53e/ * migrate old config to new config * fix bug risks * Format code with gofmt This commit fixes the style issues introduced in 0ea8eb2 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f90cf664-8396-4b78-814d-3167ce898164/ * refactoring Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2020-09-29 05:55:34 +00:00
2020-12-21 15:59:47 +00:00
apiClient, err := f.HttpClient()
if err != nil {
return err
}
Isolate commands into separate sub-packages (#229) * refactor: organize commands into separate subfolders * Format code with gofmt This commit fixes the style issues introduced in d1f70d5 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/1ce57d1c-4f1e-48c2-a4d8-00c1bce7fb49/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in ca0bff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/11379011-98c6-43ea-8baa-4fefa9b775e4/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in 00e5936 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/c912f945-acf3-48d2-a550-0895c0153df0/ * Done with sub-packaging 🔥 * 🔥 tests * Format code with gofmt This commit fixes the style issues introduced in 56a8ff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/24498865-4980-479f-90c7-7ddd228c2bb4/ * fix bug risks * fix tests * fix tests * Format code with gofmt This commit fixes the style issues introduced in c947d02 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/cb2ac46a-f857-40d5-8508-eacc253b3614/ * Format code with gofmt This commit fixes the style issues introduced in 902ff7b according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f60ba0d6-94d3-47c0-ae27-568a5cc5d9e5/ * fix tests * fix tests * 🔥 gookit/color * Format code with gofmt This commit fixes the style issues introduced in 5a129ea according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/8f1c8327-f5c6-4ff5-97d2-3c8a23f0a1e2/ * Autofix issues in 1 files Resolved issues in the following files via DeepSource Autofix: 1. commands/cmdtest/helper.go * add tests for MR * Format code with gofmt This commit fixes the style issues introduced in 758af28 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/d55a4867-aa23-4202-b2cc-a7ceafbaa53e/ * migrate old config to new config * fix bug risks * Format code with gofmt This commit fixes the style issues introduced in 0ea8eb2 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f90cf664-8396-4b78-814d-3167ce898164/ * refactoring Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2020-09-29 05:55:34 +00:00
repo, err := f.BaseRepo()
if err != nil {
return fmt.Errorf("You need to be in a GitLab project repository for this action.\nError: %s", err)
}
project, err := repo.Project(apiClient)
if err != nil {
return fmt.Errorf("You need to be in a GitLab project repository for this action.\nError: %s", err)
}
projectID := project.ID
Isolate commands into separate sub-packages (#229) * refactor: organize commands into separate subfolders * Format code with gofmt This commit fixes the style issues introduced in d1f70d5 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/1ce57d1c-4f1e-48c2-a4d8-00c1bce7fb49/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in ca0bff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/11379011-98c6-43ea-8baa-4fefa9b775e4/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in 00e5936 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/c912f945-acf3-48d2-a550-0895c0153df0/ * Done with sub-packaging 🔥 * 🔥 tests * Format code with gofmt This commit fixes the style issues introduced in 56a8ff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/24498865-4980-479f-90c7-7ddd228c2bb4/ * fix bug risks * fix tests * fix tests * Format code with gofmt This commit fixes the style issues introduced in c947d02 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/cb2ac46a-f857-40d5-8508-eacc253b3614/ * Format code with gofmt This commit fixes the style issues introduced in 902ff7b according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f60ba0d6-94d3-47c0-ae27-568a5cc5d9e5/ * fix tests * fix tests * 🔥 gookit/color * Format code with gofmt This commit fixes the style issues introduced in 5a129ea according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/8f1c8327-f5c6-4ff5-97d2-3c8a23f0a1e2/ * Autofix issues in 1 files Resolved issues in the following files via DeepSource Autofix: 1. commands/cmdtest/helper.go * add tests for MR * Format code with gofmt This commit fixes the style issues introduced in 758af28 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/d55a4867-aa23-4202-b2cc-a7ceafbaa53e/ * migrate old config to new config * fix bug risks * Format code with gofmt This commit fixes the style issues introduced in 0ea8eb2 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f90cf664-8396-4b78-814d-3167ce898164/ * refactoring Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2020-09-29 05:55:34 +00:00
2020-12-21 15:59:47 +00:00
var content []byte
var stdout bytes.Buffer
Isolate commands into separate sub-packages (#229) * refactor: organize commands into separate subfolders * Format code with gofmt This commit fixes the style issues introduced in d1f70d5 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/1ce57d1c-4f1e-48c2-a4d8-00c1bce7fb49/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in ca0bff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/11379011-98c6-43ea-8baa-4fefa9b775e4/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in 00e5936 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/c912f945-acf3-48d2-a550-0895c0153df0/ * Done with sub-packaging 🔥 * 🔥 tests * Format code with gofmt This commit fixes the style issues introduced in 56a8ff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/24498865-4980-479f-90c7-7ddd228c2bb4/ * fix bug risks * fix tests * fix tests * Format code with gofmt This commit fixes the style issues introduced in c947d02 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/cb2ac46a-f857-40d5-8508-eacc253b3614/ * Format code with gofmt This commit fixes the style issues introduced in 902ff7b according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f60ba0d6-94d3-47c0-ae27-568a5cc5d9e5/ * fix tests * fix tests * 🔥 gookit/color * Format code with gofmt This commit fixes the style issues introduced in 5a129ea according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/8f1c8327-f5c6-4ff5-97d2-3c8a23f0a1e2/ * Autofix issues in 1 files Resolved issues in the following files via DeepSource Autofix: 1. commands/cmdtest/helper.go * add tests for MR * Format code with gofmt This commit fixes the style issues introduced in 758af28 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/d55a4867-aa23-4202-b2cc-a7ceafbaa53e/ * migrate old config to new config * fix bug risks * Format code with gofmt This commit fixes the style issues introduced in 0ea8eb2 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f90cf664-8396-4b78-814d-3167ce898164/ * refactoring Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2020-09-29 05:55:34 +00:00
2020-12-21 15:59:47 +00:00
if git.IsValidURL(path) {
resp, err := http.Get(path)
if err != nil {
return err
}
_, err = io.Copy(&stdout, resp.Body)
if err != nil {
return err
}
content = stdout.Bytes()
} else {
2022-11-30 12:45:08 +00:00
content, err = os.ReadFile(path)
2020-12-21 15:59:47 +00:00
if err != nil {
if os.IsNotExist(err) {
return fmt.Errorf("%s: no such file or directory", path)
Isolate commands into separate sub-packages (#229) * refactor: organize commands into separate subfolders * Format code with gofmt This commit fixes the style issues introduced in d1f70d5 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/1ce57d1c-4f1e-48c2-a4d8-00c1bce7fb49/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in ca0bff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/11379011-98c6-43ea-8baa-4fefa9b775e4/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in 00e5936 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/c912f945-acf3-48d2-a550-0895c0153df0/ * Done with sub-packaging 🔥 * 🔥 tests * Format code with gofmt This commit fixes the style issues introduced in 56a8ff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/24498865-4980-479f-90c7-7ddd228c2bb4/ * fix bug risks * fix tests * fix tests * Format code with gofmt This commit fixes the style issues introduced in c947d02 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/cb2ac46a-f857-40d5-8508-eacc253b3614/ * Format code with gofmt This commit fixes the style issues introduced in 902ff7b according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f60ba0d6-94d3-47c0-ae27-568a5cc5d9e5/ * fix tests * fix tests * 🔥 gookit/color * Format code with gofmt This commit fixes the style issues introduced in 5a129ea according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/8f1c8327-f5c6-4ff5-97d2-3c8a23f0a1e2/ * Autofix issues in 1 files Resolved issues in the following files via DeepSource Autofix: 1. commands/cmdtest/helper.go * add tests for MR * Format code with gofmt This commit fixes the style issues introduced in 758af28 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/d55a4867-aa23-4202-b2cc-a7ceafbaa53e/ * migrate old config to new config * fix bug risks * Format code with gofmt This commit fixes the style issues introduced in 0ea8eb2 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f90cf664-8396-4b78-814d-3167ce898164/ * refactoring Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2020-09-29 05:55:34 +00:00
}
2020-12-21 15:59:47 +00:00
return err
}
}
Isolate commands into separate sub-packages (#229) * refactor: organize commands into separate subfolders * Format code with gofmt This commit fixes the style issues introduced in d1f70d5 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/1ce57d1c-4f1e-48c2-a4d8-00c1bce7fb49/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in ca0bff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/11379011-98c6-43ea-8baa-4fefa9b775e4/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in 00e5936 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/c912f945-acf3-48d2-a550-0895c0153df0/ * Done with sub-packaging 🔥 * 🔥 tests * Format code with gofmt This commit fixes the style issues introduced in 56a8ff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/24498865-4980-479f-90c7-7ddd228c2bb4/ * fix bug risks * fix tests * fix tests * Format code with gofmt This commit fixes the style issues introduced in c947d02 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/cb2ac46a-f857-40d5-8508-eacc253b3614/ * Format code with gofmt This commit fixes the style issues introduced in 902ff7b according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f60ba0d6-94d3-47c0-ae27-568a5cc5d9e5/ * fix tests * fix tests * 🔥 gookit/color * Format code with gofmt This commit fixes the style issues introduced in 5a129ea according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/8f1c8327-f5c6-4ff5-97d2-3c8a23f0a1e2/ * Autofix issues in 1 files Resolved issues in the following files via DeepSource Autofix: 1. commands/cmdtest/helper.go * add tests for MR * Format code with gofmt This commit fixes the style issues introduced in 758af28 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/d55a4867-aa23-4202-b2cc-a7ceafbaa53e/ * migrate old config to new config * fix bug risks * Format code with gofmt This commit fixes the style issues introduced in 0ea8eb2 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f90cf664-8396-4b78-814d-3167ce898164/ * refactoring Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2020-09-29 05:55:34 +00:00
fmt.Fprintln(f.IO.StdOut, "Validating...")
2020-12-21 15:59:47 +00:00
lint, err := api.ProjectNamespaceLint(apiClient, projectID, string(content), ref, dryRun, includeJobs)
2020-12-21 15:59:47 +00:00
if err != nil {
return err
Isolate commands into separate sub-packages (#229) * refactor: organize commands into separate subfolders * Format code with gofmt This commit fixes the style issues introduced in d1f70d5 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/1ce57d1c-4f1e-48c2-a4d8-00c1bce7fb49/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in ca0bff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/11379011-98c6-43ea-8baa-4fefa9b775e4/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in 00e5936 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/c912f945-acf3-48d2-a550-0895c0153df0/ * Done with sub-packaging 🔥 * 🔥 tests * Format code with gofmt This commit fixes the style issues introduced in 56a8ff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/24498865-4980-479f-90c7-7ddd228c2bb4/ * fix bug risks * fix tests * fix tests * Format code with gofmt This commit fixes the style issues introduced in c947d02 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/cb2ac46a-f857-40d5-8508-eacc253b3614/ * Format code with gofmt This commit fixes the style issues introduced in 902ff7b according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f60ba0d6-94d3-47c0-ae27-568a5cc5d9e5/ * fix tests * fix tests * 🔥 gookit/color * Format code with gofmt This commit fixes the style issues introduced in 5a129ea according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/8f1c8327-f5c6-4ff5-97d2-3c8a23f0a1e2/ * Autofix issues in 1 files Resolved issues in the following files via DeepSource Autofix: 1. commands/cmdtest/helper.go * add tests for MR * Format code with gofmt This commit fixes the style issues introduced in 758af28 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/d55a4867-aa23-4202-b2cc-a7ceafbaa53e/ * migrate old config to new config * fix bug risks * Format code with gofmt This commit fixes the style issues introduced in 0ea8eb2 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f90cf664-8396-4b78-814d-3167ce898164/ * refactoring Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2020-09-29 05:55:34 +00:00
}
if !lint.Valid {
2021-01-29 00:56:45 +00:00
fmt.Fprintln(out, c.Red(path+" is invalid"))
2020-12-21 15:59:47 +00:00
for i, err := range lint.Errors {
i++
fmt.Fprintln(out, i, err)
}
// Returning the error to cobra here causes the process to exit with code 0, so we exit manually.
os.Exit(1)
2020-12-21 15:59:47 +00:00
}
fmt.Fprintln(out, c.GreenCheck(), "CI/CD YAML is valid!")
2020-12-21 15:59:47 +00:00
return nil
Isolate commands into separate sub-packages (#229) * refactor: organize commands into separate subfolders * Format code with gofmt This commit fixes the style issues introduced in d1f70d5 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/1ce57d1c-4f1e-48c2-a4d8-00c1bce7fb49/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in ca0bff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/11379011-98c6-43ea-8baa-4fefa9b775e4/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in 00e5936 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/c912f945-acf3-48d2-a550-0895c0153df0/ * Done with sub-packaging 🔥 * 🔥 tests * Format code with gofmt This commit fixes the style issues introduced in 56a8ff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/24498865-4980-479f-90c7-7ddd228c2bb4/ * fix bug risks * fix tests * fix tests * Format code with gofmt This commit fixes the style issues introduced in c947d02 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/cb2ac46a-f857-40d5-8508-eacc253b3614/ * Format code with gofmt This commit fixes the style issues introduced in 902ff7b according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f60ba0d6-94d3-47c0-ae27-568a5cc5d9e5/ * fix tests * fix tests * 🔥 gookit/color * Format code with gofmt This commit fixes the style issues introduced in 5a129ea according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/8f1c8327-f5c6-4ff5-97d2-3c8a23f0a1e2/ * Autofix issues in 1 files Resolved issues in the following files via DeepSource Autofix: 1. commands/cmdtest/helper.go * add tests for MR * Format code with gofmt This commit fixes the style issues introduced in 758af28 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/d55a4867-aa23-4202-b2cc-a7ceafbaa53e/ * migrate old config to new config * fix bug risks * Format code with gofmt This commit fixes the style issues introduced in 0ea8eb2 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f90cf664-8396-4b78-814d-3167ce898164/ * refactoring Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2020-09-29 05:55:34 +00:00
}