avoid kubernetes import for slice contains logic (#4963)

* avoid kubernetes import for slice contains logic

Signed-off-by: tariqibrahim <tariq.ibrahim@microsoft.com>

* fix review comments

Signed-off-by: tariqibrahim <tariq.ibrahim@microsoft.com>
pull/4981/head
Tariq Ibrahim 6 years ago committed by Matthew Fisher
parent a34baf0eea
commit c095b9232d

@ -18,15 +18,13 @@ 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"
"k8s.io/kubernetes/pkg/util/slice"
) )
const inspectDesc = ` const inspectDesc = `
@ -256,9 +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 slice.ContainsString(readmeFileNames, strings.ToLower(file.TypeUrl), nil) { if containsString(readmeFileNames, strings.ToLower(file.TypeUrl), nil) {
return file return file
} }
} }
return nil return nil
} }
// 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
}

Loading…
Cancel
Save