-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Running command `dunner validate` will check for any parse errors and warnings. If there are any errors, it fails the cmd, if not it finishes by listing any warnings if present.
- Loading branch information
Showing
6 changed files
with
132 additions
and
6 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,18 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/leopardslab/Dunner/pkg/config" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func init() { | ||
rootCmd.AddCommand(validateCmd) | ||
} | ||
|
||
var validateCmd = &cobra.Command{ | ||
Use: "validate", | ||
Short: "Validate the dunner task file `.dunner.yaml`", | ||
Long: "You can validate task file `.dunner.yaml` with this command to see if there are any parse errors", | ||
Run: config.Validate, | ||
Args: cobra.MinimumNArgs(0), | ||
} |
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
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,25 @@ | ||
package config | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
func Validate(_ *cobra.Command, args []string) { | ||
var dunnerFile = viper.GetString("DunnerTaskFile") | ||
|
||
configs, err := GetConfigs(dunnerFile) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
errs, ok := configs.Validate() | ||
for _, err := range errs { | ||
log.Error(err) | ||
} | ||
if !ok { | ||
os.Exit(1) | ||
} | ||
} |
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