/
syntax.go
53 lines (41 loc) · 1.44 KB
/
syntax.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package cmd
import (
"strings"
"github.com/apex/log"
"github.com/spf13/cobra"
"github.com/little-angry-clouds/particle/internal/cli"
"github.com/little-angry-clouds/particle/internal/config"
customError "github.com/little-angry-clouds/particle/internal/error"
"github.com/little-angry-clouds/particle/internal/helpers"
)
func syntax(cmd *cobra.Command, args []string) {
var scenario string
var configuration config.ParticleConfiguration
var err error
var debug bool
debug, _ = cmd.Flags().GetBool("debug")
logger := helpers.GetLogger(debug)
scenario, _ = cmd.Flags().GetString("scenario")
logger.Info("Begin syntax")
configuration, err = config.ReadConfiguration(scenario)
customError.CheckGenericError(logger, err)
logger.WithFields(log.Fields{
"driver": configuration.Driver.Name,
"provisioner": configuration.Provisioner.Name,
"verifier": strings.Replace(configuration.Verifier, "\n", " && ", -1),
"linter": strings.Replace(configuration.Linter, "\n", " && ", -1),
}).Debug("Configuration to use")
err = cli.Syntax(configuration, logger)
customError.CheckGenericError(logger, err)
logger.Info("Syntax finished")
}
// syntaxCmd represents the syntax command
var syntaxCmd = &cobra.Command{
Use: "syntax",
Short: "Checks that the particle configuration is correct",
Run: syntax,
}
func init() {
rootCmd.AddCommand(syntaxCmd)
syntaxCmd.PersistentFlags().StringP("scenario", "s", "default", "scenario to use")
}