mirror of https://gitlab.com/gitlab-org/cli.git
feat(lint): provide dry-run, include-jobs and ref options
This commit is contained in:
parent
b84ce07873
commit
8bace091b4
|
@ -389,14 +389,17 @@ var PipelineJobsWithSha = func(client *gitlab.Client, pid interface{}, sha strin
|
|||
return PipelineJobsWithID(client, pid, pipelines[0].ID)
|
||||
}
|
||||
|
||||
var ProjectNamespaceLint = func(client *gitlab.Client, projectID int, content string) (*gitlab.ProjectLintResult, error) {
|
||||
var ProjectNamespaceLint = func(client *gitlab.Client, projectID int, content string, ref string, dryRun bool, includeJobs bool) (*gitlab.ProjectLintResult, error) {
|
||||
if client == nil {
|
||||
client = apiClient.Lab()
|
||||
}
|
||||
c, _, err := client.Validate.ProjectNamespaceLint(
|
||||
projectID,
|
||||
&gitlab.ProjectNamespaceLintOptions{
|
||||
Content: &content,
|
||||
Content: &content,
|
||||
DryRun: &dryRun,
|
||||
Ref: &ref,
|
||||
IncludeJobs: &includeJobs,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
|
|
|
@ -15,6 +15,12 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
ref string
|
||||
dryRun bool
|
||||
includeJobs bool
|
||||
)
|
||||
|
||||
func NewCmdLint(f *cmdutils.Factory) *cobra.Command {
|
||||
pipelineCILintCmd := &cobra.Command{
|
||||
Use: "lint",
|
||||
|
@ -37,6 +43,10 @@ func NewCmdLint(f *cmdutils.Factory) *cobra.Command {
|
|||
},
|
||||
}
|
||||
|
||||
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.")
|
||||
|
||||
return pipelineCILintCmd
|
||||
}
|
||||
|
||||
|
@ -87,7 +97,7 @@ func lintRun(f *cmdutils.Factory, path string) error {
|
|||
|
||||
fmt.Fprintln(f.IO.StdOut, "Validating...")
|
||||
|
||||
lint, err := api.ProjectNamespaceLint(apiClient, projectID, string(content))
|
||||
lint, err := api.ProjectNamespaceLint(apiClient, projectID, string(content), ref, dryRun, includeJobs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -29,6 +29,14 @@ $ glab ci lint path/to/.gitlab-ci.yml
|
|||
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
```plaintext
|
||||
--dry-run Run pipeline creation simulation.
|
||||
--include-jobs The response should include the list of jobs that would exist in a static check or pipeline simulation.
|
||||
--ref string When dry-run is true, sets the branch or tag context for validating the CI/CD YAML configuration.
|
||||
```
|
||||
|
||||
## Options inherited from parent commands
|
||||
|
||||
```plaintext
|
||||
|
|
|
@ -29,6 +29,14 @@ $ glab ci lint path/to/.gitlab-ci.yml
|
|||
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
```plaintext
|
||||
--dry-run Run pipeline creation simulation.
|
||||
--include-jobs The response should include the list of jobs that would exist in a static check or pipeline simulation.
|
||||
--ref string When dry-run is true, sets the branch or tag context for validating the CI/CD YAML configuration.
|
||||
```
|
||||
|
||||
## Options inherited from parent commands
|
||||
|
||||
```plaintext
|
||||
|
|
Loading…
Reference in New Issue