This repository has been archived by the owner on Nov 22, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: live pipeline gui view with keybinded controls
- Loading branch information
Showing
10 changed files
with
1,138 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package commands | ||
|
||
import ( | ||
"fmt" | ||
"github.com/MakeNowJust/heredoc" | ||
"github.com/gookit/color" | ||
"io/ioutil" | ||
"log" | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// ciLintCmd represents the lint command | ||
var pipelineCILintCmd = &cobra.Command{ | ||
Use: "lint", | ||
Short: "Checks if your .gitlab-ci.yml file is valid.", | ||
Long: ``, | ||
Example: heredoc.Doc(` | ||
$ glab pipeline ci lint # Uses .gitlab-ci.yml in the current directory | ||
$ glab pipeline ci lint .gitlab-ci.yml | ||
$ glab pipeline ci lint path/to/.gitlab-ci.yml | ||
`), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
path := ".gitlab-ci.yml" | ||
if len(args) == 1 { | ||
path = args[0] | ||
} | ||
fmt.Println("Getting contents in", path) | ||
|
||
content, err := ioutil.ReadFile(path) | ||
if !os.IsNotExist(err) && err != nil { | ||
log.Fatal(err) | ||
} | ||
fmt.Println("Validating...") | ||
lint, err := pipelineCILint(string(content)) | ||
if err != nil { | ||
er(err) | ||
return | ||
} | ||
if lint.Status == "invalid" { | ||
color.Red.Println(path, "is invalid") | ||
for i, err := range lint.Errors { | ||
i++ | ||
fmt.Println(i, err) | ||
return | ||
} | ||
} | ||
color.Green.Println("CI yml is Valid!") | ||
return | ||
}, | ||
} | ||
|
||
func init() { | ||
pipelineCICmd.AddCommand(pipelineCILintCmd) | ||
} |
Oops, something went wrong.