github.com/tilt-dev/tilt@v0.36.0/internal/cli/visitor/strings.go (about) 1 package visitor 2 3 import ( 4 "io" 5 "net/http" 6 "net/url" 7 "strings" 8 9 "github.com/pkg/errors" 10 ) 11 12 // Convert a list of filenames into YAML inputs. 13 func FromStrings(filenames []string, stdin io.Reader) ([]Interface, error) { 14 result := []Interface{} 15 for _, f := range filenames { 16 17 switch { 18 case f == "-": 19 result = append(result, Stdin(stdin)) 20 21 case strings.Index(f, "http://") == 0 || strings.Index(f, "https://") == 0: 22 url, err := url.Parse(f) 23 if err != nil { 24 return nil, errors.Wrapf(err, "invalid URL %s", url) 25 } 26 result = append(result, URL(http.DefaultClient, f)) 27 28 default: 29 result = append(result, File(f)) 30 31 } 32 } 33 return result, nil 34 }