github.com/grahambrereton-form3/tilt@v0.10.18/internal/tiltfile/helm.go (about)

     1  package tiltfile
     2  
     3  import (
     4  	"regexp"
     5  	"strings"
     6  )
     7  
     8  // The helm template command outputs predictable yaml with a "Source:" comment,
     9  // so take advantage of that.
    10  const helmSeparator = "---\n"
    11  
    12  var helmTestYAMLMatcher = regexp.MustCompile("^# Source: .*/tests/")
    13  
    14  func filterHelmTestYAML(resourceBlob string) string {
    15  	result := []string{}
    16  	resources := strings.Split(resourceBlob, helmSeparator)
    17  	for _, resource := range resources {
    18  		if isHelmTestYAML(resource) {
    19  			continue
    20  		}
    21  
    22  		result = append(result, resource)
    23  	}
    24  	return strings.Join(result, helmSeparator)
    25  }
    26  
    27  func isHelmTestYAML(resource string) bool {
    28  	lines := strings.Split(resource, "\n")
    29  	for _, line := range lines {
    30  		if helmTestYAMLMatcher.MatchString(line) {
    31  			return true
    32  		}
    33  	}
    34  	return false
    35  }