Fixup luet tree pkglist/images while having shared templates

This commit is contained in:
Ettore Di Giacinto
2021-08-11 12:52:16 +02:00
parent 0cc8930708
commit b81d33f182
4 changed files with 112 additions and 106 deletions

View File

@@ -17,13 +17,14 @@ package util
import (
"errors"
"path/filepath"
"strings"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/mudler/luet/pkg/config"
. "github.com/mudler/luet/pkg/config"
"github.com/mudler/luet/pkg/installer"
)
func BindSystemFlags(cmd *cobra.Command) {
@@ -40,11 +41,11 @@ func BindSolverFlags(cmd *cobra.Command) {
}
func BindValuesFlags(cmd *cobra.Command) {
viper.BindPFlag("values", cmd.Flags().Lookup("values"))
LuetCfg.Viper.BindPFlag("values", cmd.Flags().Lookup("values"))
}
func ValuesFlags() []string {
return viper.GetStringSlice("values")
return LuetCfg.Viper.GetStringSlice("values")
}
func SetSystemConfig() {
@@ -91,3 +92,18 @@ func SetCliFinalizerEnvs(finalizerEnvs []string) error {
return nil
}
// TemplateFolders returns the default folders which holds shared template between packages in a given tree path
func TemplateFolders(fromRepo bool, treePaths []string) []string {
templateFolders := []string{}
if !fromRepo {
for _, t := range treePaths {
templateFolders = append(templateFolders, filepath.Join(t, "templates"))
}
} else {
for _, s := range installer.SystemRepositories(LuetCfg) {
templateFolders = append(templateFolders, filepath.Join(s.TreePath, "templates"))
}
}
return templateFolders
}