handle empty pipeline name in lookup

This commit is contained in:
Brad Rydzewski
2019-10-30 15:52:10 -07:00
parent 5b1d8d65ed
commit cab335542b
2 changed files with 23 additions and 1 deletions

View File

@@ -13,7 +13,7 @@ import (
// Lookup returns the named pipeline from the Manifest.
func Lookup(name string, manifest *manifest.Manifest) (*Pipeline, error) {
for _, resource := range manifest.Resources {
if resource.GetName() != name {
if !isNameMatch(resource.GetName(), name) {
continue
}
if pipeline, ok := resource.(*Pipeline); ok {
@@ -22,3 +22,8 @@ func Lookup(name string, manifest *manifest.Manifest) (*Pipeline, error) {
}
return nil, errors.New("resource not found")
}
// helper function returns true if the name matches.
func isNameMatch(a, b string) bool {
return a == b || (a == "" && b == "default")
}