Skip to content

Commit

Permalink
feat: add linting
Browse files Browse the repository at this point in the history
  • Loading branch information
alexppg committed Feb 21, 2021
1 parent 5ea01eb commit d92f0f7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
6 changes: 4 additions & 2 deletions cmd/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ import (
)

func chart(cmd *cobra.Command, args []string) {
var driver string = "kind"
var chartName string = args[0]
// TODO add support to manage scenarios
var scenario string = "default"
var driver string = "kind"
var chartName string = args[0]
var supportedDrivers = []string{driver}
var err error
var configuration config.ParticleConfiguration
var lint string = "set -e\nhelm lint"

driver, err = cmd.Flags().GetString("driver")
helpers.CheckGenericError(err)
Expand Down Expand Up @@ -49,6 +50,7 @@ func chart(cmd *cobra.Command, args []string) {

configuration.Driver.Name = driver
configuration.Provisioner.Name = "helm"
configuration.Lint = lint
err = config.CreateConfiguration(chartName, scenario, configuration)
helpers.CheckGenericError(err)
fmt.Println("Particle initialized.")
Expand Down
32 changes: 26 additions & 6 deletions cmd/lint.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"

c "github.com/little-angry-clouds/particle/internal/cmd"
"github.com/little-angry-clouds/particle/internal/config"
"github.com/little-angry-clouds/particle/internal/helpers"
)

func lint(cmd *cobra.Command, args []string) {
// TODO add support to manage scenarios
var scenario string = "default"
var configuration config.ParticleConfiguration
var err error
var cli c.CLI

configuration, err = config.ReadConfiguration(scenario)
helpers.CheckGenericError(err)

cli = c.CLI{Binary: "bash"}
cmdArgs := []string{"bash", "-c", configuration.Lint}

err = cli.Initialize(cmdArgs)
helpers.CheckGenericError(err)

err = cli.Run()
helpers.CheckGenericError(err)
}

// lintCmd represents the lint command
var lintCmd = &cobra.Command{
Use: "lint",
Short: "A brief description of your command",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("lint called")
},
Short: "Lint command executes external linters",
Run: lint,
}

func init() {
Expand Down
1 change: 1 addition & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type Key string
type ParticleConfiguration struct {
Driver Driver `yaml:"driver"`
Provisioner Provisioner `yaml:"provisioner"`
Lint string `yaml:"lint"`
}

type Driver struct {
Expand Down

0 comments on commit d92f0f7

Please sign in to comment.