chore(): fix linting issues

pull/6096/head^2
Art Begolli 6 years ago
parent 4d298f600e
commit edf38f8e88

@ -52,15 +52,15 @@ type searchCmd struct {
output string output string
} }
type ResultEntry struct { type resultEntry struct {
Name string `json:"name"` Name string `json:"name"`
ChartVersion string `json:"chartVersion"` ChartVersion string `json:"chartVersion"`
AppVersion string `json:"appVersion"` AppVersion string `json:"appVersion"`
Description string `json:"description"` Description string `json:"description"`
} }
type Results struct { type results struct {
SearchResults []ResultEntry `json:"searchResults"` SearchResults []resultEntry `json:"searchResults"`
} }
func newSearchCmd(out io.Writer) *cobra.Command { func newSearchCmd(out io.Writer) *cobra.Command {
@ -110,7 +110,7 @@ func (s *searchCmd) run(args []string) error {
} }
if s.output == "json" { if s.output == "json" {
formattedResults, err := s.formatSearchResultsJson(data, s.colWidth) formattedResults, err := s.formatSearchResultsJSON(data, s.colWidth)
if err != nil { if err != nil {
return err return err
} }
@ -165,23 +165,23 @@ func (s *searchCmd) formatSearchResults(res []*search.Result, colWidth uint) str
return table.String() return table.String()
} }
func (s *searchCmd) formatSearchResultsJson(res []*search.Result, colWidth uint) (string, error) { func (s *searchCmd) formatSearchResultsJSON(res []*search.Result, colWidth uint) (string, error) {
var resultJson []ResultEntry var resultJSON []resultEntry
if len(res) == 0 { if len(res) == 0 {
return "No results found", nil return "No results found", nil
} }
for _, r := range res { for _, r := range res {
resultRow := ResultEntry{ resultRow := resultEntry{
Name: r.Name, Name: r.Name,
ChartVersion: r.Chart.Version, ChartVersion: r.Chart.Version,
AppVersion: r.Chart.AppVersion, AppVersion: r.Chart.AppVersion,
Description: r.Chart.Description, Description: r.Chart.Description,
} }
resultJson = append(resultJson, resultRow) resultJSON = append(resultJSON, resultRow)
} }
jsonSearchResults, err := json.MarshalIndent(Results{SearchResults: resultJson}, "", " ") jsonSearchResults, err := json.MarshalIndent(results{SearchResults: resultJSON}, "", " ")
if err != nil { if err != nil {
return "", err return "", err
} }

Loading…
Cancel
Save