github.com/Racer159/jackal@v0.32.7-0.20240401174413-0bd2339e4f2e/src/internal/packager/template/yaml.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // SPDX-FileCopyrightText: 2021-Present The Jackal Authors
     3  
     4  // Package template provides functions for templating yaml files.
     5  package template
     6  
     7  import (
     8  	"regexp"
     9  
    10  	"github.com/Racer159/jackal/src/types"
    11  	"github.com/defenseunicorns/pkg/helpers"
    12  )
    13  
    14  // ProcessYamlFilesInPath iterates over all yaml files in a given path and performs Jackal templating + image swapping.
    15  func ProcessYamlFilesInPath(path string, component types.JackalComponent, values Values) ([]string, error) {
    16  	// Only pull in yml and yaml files
    17  	pattern := regexp.MustCompile(`(?mi)\.ya?ml$`)
    18  	manifests, _ := helpers.RecursiveFileList(path, pattern, false)
    19  
    20  	for _, manifest := range manifests {
    21  		if err := values.Apply(component, manifest, false); err != nil {
    22  			return nil, err
    23  		}
    24  	}
    25  
    26  	return manifests, nil
    27  }