Пример #1
0
func CreateDump(options map[string]string) {
	name := options["name"]
	if name == "" {
		ShowUsage()
		return
	}
	CheckConfig()
	perm := os.FileMode(0777)
	// TODO: Check if specified bundle has already been created
	for sourceName, conf := range config.Sources {
		source := sourceRegistry[conf.Type]
		if source != nil {
			path := fmt.Sprintf(".dklocal/%v/%v", name, sourceName)
			os.MkdirAll(path, perm)
			source.Setup(&conf)
			err := source.CreateDump(path)
			if err != nil {
				fmt.Println(err)
				os.Exit(1)
			}
		}
	}
	// TODO: Create timestamp (when bundle has been created) in case some sources were specified
	ArchiveBundle(name)
}
Пример #2
0
func ApplyDump(options map[string]string) {
	name := options["name"]
	if name == "" {
		ShowUsage()
		return
	}
	CheckConfig()
	UnarchiveBundle(name, func() {
		for sourceName, conf := range config.Sources {
			source := sourceRegistry[conf.Type]
			if source != nil {
				path := fmt.Sprintf(".dklocal/%v/%v", name, sourceName)
				// TODO: Check if this path exists
				source.Setup(&conf)
				err := source.ApplyDump(path)
				if err != nil {
					fmt.Println(err)
					os.Exit(1)
				}
			}
		}
	})
}