From fc6d0178364fa9d289df73c8b1d512b7b8f7eb45 Mon Sep 17 00:00:00 2001 From: tariqibrahim Date: Wed, 28 Nov 2018 11:20:58 -0800 Subject: [PATCH] fix review comments Signed-off-by: tariqibrahim --- cmd/helm/inspect.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cmd/helm/inspect.go b/cmd/helm/inspect.go index 6514c92ca..844116bc5 100644 --- a/cmd/helm/inspect.go +++ b/cmd/helm/inspect.go @@ -18,12 +18,11 @@ package main import ( "fmt" - "io" - "strings" - "github.com/ghodss/yaml" "github.com/golang/protobuf/ptypes/any" "github.com/spf13/cobra" + "io" + "strings" "k8s.io/helm/pkg/chartutil" ) @@ -255,18 +254,23 @@ func (i *inspectCmd) run() error { func findReadme(files []*any.Any) (file *any.Any) { for _, file := range files { - if contains(readmeFileNames, strings.ToLower(file.TypeUrl)) { + if containsString(readmeFileNames, strings.ToLower(file.TypeUrl), nil) { return file } } 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 { if item == s { return true } + if modifier != nil && modifier(item) == s { + return true + } } return false }