// ParseTemplate can be used to parse the given go template.
ParseTemplate can be used to parse the given go template.
// ParseTemplate can be used to parse the given go template .
func ParseTemplate(dsc string) (string, error) {
	var (
		fm = template.FuncMap{
			"env":     getEnv,
			"default": setDefaultValue,
			"var":     getVar,
		}
		parsedTemplateFileName = "output.yml"
	)
	fileInfo, err := os.Stat(dsc)
	if os.IsNotExist(err) {
		return "", err
	}
	clogger.Debug("")
	clogger.Debug("Template Found At :-> ", dsc)
	dscName := fileInfo.Name()
	tmplPtr, err := template.New(dscName).Funcs(fm).ParseFiles(dsc)
	if err != nil {
		return "", err
	}
	file, err := os.Create(parsedTemplateFileName)
	if err != nil {
		return "", err
	}
	defer file.Close()
	err = tmplPtr.Execute(file, nil)
	if err != nil {
		return parsedTemplateFileName, err
	}
	return parsedTemplateFileName, nil
}
func ParseTemplate ( dsc string ) ( string , error ) { var ( fm = template . FuncMap { " " : getEnv , " " : setDefaultValue , " " : getVar , } parsedTemplateFileName = " " ) fileInfo , err := os . Stat ( dsc ) if os . IsNotExist ( err ) { return " " , err } clogger . Debug ( " " ) clogger . Debug ( " " , dsc ) dscName := fileInfo . Name ( ) tmplPtr , err := template . New ( dscName ) . Funcs ( fm ) . ParseFiles ( dsc ) if err != nil { return " " , err } file , err := os . Create ( parsedTemplateFileName ) if err != nil { return " " , err } defer file . Close ( ) err = tmplPtr . Execute ( file , nil ) if err != nil { return parsedTemplateFileName , err } return parsedTemplateFileName , nil }
ParseTemplate can be used to parse the given go template.
ParseTemplate can be used to parse the given go template .
// Create output file for storing parsed template content // parsedTemplateFileName = uuid.New().String() + ".yml" // Create template object for given dsc // Parse given dsc template