fix review comments

Signed-off-by: tariqibrahim <tariq.ibrahim@microsoft.com>
pull/4963/head
tariqibrahim 7 years ago
parent c89bc33b92
commit fc6d017836

@ -18,12 +18,11 @@ package main
import ( import (
"fmt" "fmt"
"io"
"strings"
"github.com/ghodss/yaml" "github.com/ghodss/yaml"
"github.com/golang/protobuf/ptypes/any" "github.com/golang/protobuf/ptypes/any"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"io"
"strings"
"k8s.io/helm/pkg/chartutil" "k8s.io/helm/pkg/chartutil"
) )
@ -255,18 +254,23 @@ func (i *inspectCmd) run() error {
func findReadme(files []*any.Any) (file *any.Any) { func findReadme(files []*any.Any) (file *any.Any) {
for _, file := range files { for _, file := range files {
if contains(readmeFileNames, strings.ToLower(file.TypeUrl)) { if containsString(readmeFileNames, strings.ToLower(file.TypeUrl), nil) {
return file return file
} }
} }
return nil return nil
} }
func contains(slice []string, s string) bool { // containsString checks if a given slice of strings contains the provided string.
// If a modifier func is provided, it is called with the slice item before the comparison.
func containsString(slice []string, s string, modifier func(s string) string) bool {
for _, item := range slice { for _, item := range slice {
if item == s { if item == s {
return true return true
} }
if modifier != nil && modifier(item) == s {
return true
}
} }
return false return false
} }

Loading…
Cancel
Save