(ctx context.Context, pkgLayout *layout.PackageLayout, component v1alpha1.ZarfComponent, variableConfig *variables.VariableConfig, values value.Values, stateAccess template.StateAccess)
| 815 | } |
| 816 | |
| 817 | func processComponentFiles(ctx context.Context, pkgLayout *layout.PackageLayout, component v1alpha1.ZarfComponent, variableConfig *variables.VariableConfig, values value.Values, stateAccess template.StateAccess) (err error) { |
| 818 | l := logger.From(ctx) |
| 819 | start := time.Now() |
| 820 | l.Info("copying files", "count", len(component.Files)) |
| 821 | |
| 822 | tmpdir, err := utils.MakeTempDir(config.CommonOptions.TempDirectory) |
| 823 | if err != nil { |
| 824 | return err |
| 825 | } |
| 826 | defer func() { |
| 827 | err = errors.Join(err, os.RemoveAll(tmpdir)) |
| 828 | }() |
| 829 | |
| 830 | filesDir, err := pkgLayout.GetComponentDir(ctx, tmpdir, component.Name, layout.FilesComponentDir) |
| 831 | if err != nil { |
| 832 | return err |
| 833 | } |
| 834 | |
| 835 | for fileIdx, file := range component.Files { |
| 836 | l.Info("loading file", "name", file.Target) |
| 837 | |
| 838 | fileLocation := filepath.Join(filesDir, layout.ComponentFileRelPath(fileIdx, file.Target)) |
| 839 | |
| 840 | // If a shasum is specified check it again on deployment as well |
| 841 | if file.Shasum != "" { |
| 842 | l.Debug("Validating SHASUM", "file", file.Target) |
| 843 | if err := helpers.SHAsMatch(fileLocation, file.Shasum); err != nil { |
| 844 | return err |
| 845 | } |
| 846 | } |
| 847 | |
| 848 | // Replace temp target directory and home directory |
| 849 | target, err := config.GetAbsHomePath(strings.Replace(file.Target, "###ZARF_TEMP###", pkgLayout.DirPath(), 1)) |
| 850 | if err != nil { |
| 851 | return err |
| 852 | } |
| 853 | file.Target = target |
| 854 | |
| 855 | fileList := []string{} |
| 856 | if helpers.IsDir(fileLocation) { |
| 857 | files, err := helpers.RecursiveFileList(fileLocation, nil, false) |
| 858 | if err != nil { |
| 859 | return err |
| 860 | } |
| 861 | fileList = append(fileList, files...) |
| 862 | } else { |
| 863 | fileList = append(fileList, fileLocation) |
| 864 | } |
| 865 | |
| 866 | for _, subFile := range fileList { |
| 867 | // Check if the file looks like a text file |
| 868 | isText, err := helpers.IsTextFile(subFile) |
| 869 | if err != nil { |
| 870 | return err |
| 871 | } |
| 872 | |
| 873 | // If the file is a text file, template it |
| 874 | if isText { |
no test coverage detected