Skip to content

Commit

Permalink
update with pr feedback, removing old flags
Browse files Browse the repository at this point in the history
  • Loading branch information
dexhorthy committed Jan 20, 2020
1 parent d32e80d commit bb7463d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 36 deletions.
41 changes: 7 additions & 34 deletions cli/cmd/release_lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,62 +3,35 @@ package cmd
import (
"fmt"
"github.com/pkg/errors"
"io/ioutil"

"github.com/replicatedhq/replicated/cli/print"
"github.com/spf13/cobra"
)

func (r *runners) InitReleaseLint(parent *cobra.Command) {
cmd := &cobra.Command{
Use: "lint",
Short: "Lint a YAML",
Long: "Lint a YAML",
Short: "Lint a directory of KOTS manifests",
Long: "Lint a directory of KOTS manifests",
SilenceUsage: true,
}
parent.AddCommand(cmd)

cmd.Flags().StringVar(&r.args.lintReleaseYaml, "yaml", "", "The YAML config to lint. Use '-' to read from stdin. Cannot be used with the `yaml-file` flag.")
cmd.Flags().StringVar(&r.args.lintReleaseYamlFile, "yaml-file", "", "The file name with YAML config to lint. Cannot be used with the `yaml` flag.")
cmd.Flags().StringVar(&r.args.lintReleaseYamlDir, "yaml-dir", "", "The directory containing multiple yamls for a Kots release. Cannot be used with the `yaml` flag.")

cmd.RunE = r.releaseLint
}

func (r *runners) releaseLint(cmd *cobra.Command, args []string) error {
if r.args.lintReleaseYaml == "" && r.args.lintReleaseYamlFile == "" && r.args.lintReleaseYamlDir == "" {
if r.args.lintReleaseYamlDir == "" {
return fmt.Errorf("yaml is required")
}

if r.args.lintReleaseYaml != "" && r.args.lintReleaseYamlFile != "" {
return fmt.Errorf("only yaml or yaml-file has to be specified")
}

if r.args.lintReleaseYaml == "-" {
bytes, err := ioutil.ReadAll(r.stdin)
if err != nil {
return err
}
r.args.lintReleaseYaml = string(bytes)
}

if r.args.lintReleaseYamlFile != "" {
bytes, err := ioutil.ReadFile(r.args.lintReleaseYamlFile)
if err != nil {
return err
}
r.args.lintReleaseYaml = string(bytes)
}

if r.args.lintReleaseYamlDir != "" {
var err error
r.args.lintReleaseYaml, err = readYAMLDir(r.args.lintReleaseYamlDir)
if err != nil {
return errors.Wrap(err, "read yaml dir")
}
lintReleaseYAML, err := readYAMLDir(r.args.lintReleaseYamlDir)
if err != nil {
return errors.Wrap(err, "read yaml dir")
}

lintResult, err := r.api.LintRelease(r.appID, r.appType, r.args.lintReleaseYaml)
lintResult, err := r.api.LintRelease(r.appID, r.appType, lintReleaseYAML)
if err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions cli/cmd/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ type runnerArgs struct {
createReleasePromoteNotes string
createReleasePromoteVersion string
createReleasePromoteEnsureChannel bool
lintReleaseYaml string
lintReleaseYamlFile string
intReleaseYamlFile string
lintReleaseYamlDir string
releaseOptional bool
releaseNotes string
Expand Down

0 comments on commit bb7463d

Please sign in to comment.