Beispiel #1
0
func Parse() (Metamap, error) {
	metapath := core.Get("core.path.metadata")
	metafiles, err := util.ReadGlob(metapath + "/*.y*ml")
	metadata := Metamap{}

	if err != nil {
		return nil, err
	}

	for _, metafile := range metafiles {
		log.Debug("Found Metadata: " + metafile)
		data, err := LoadYaml(metafile)
		if err != nil {
			log.Error(err.Error())
		}
		for k, v := range data {
			metadata[k] = v
		}
	}
	return metadata, nil
}
Beispiel #2
0
In local development it is recommended to mount default.yml
using -v default.yml:/etc/kaigara/default.yml

Example: kaigara render server.conf > /etc/server.conf`,

	Run: func(cmd *cobra.Command, args []string) {

		if len(args) > 0 {
			data, err := metadata.Parse()
			template := fmt.Sprintf("%s/%s.tmpl", core.Get("core.path.resources"), args[0])

			if err != nil {
				log.Fatal(err.Error())
			}

			output, err := resource.Render(template, data)
			if err != nil {
				log.Fatal(err.Error())
			}
			fmt.Print(output)
		} else {
			log.Error("No template given")
		}
	},
}

func init() {
	RootCmd.AddCommand(renderCmd)
}