Ejemplo n.º 1
0
func exportAll(fileName string) error {
	exportedData := &ExportData{MajorVersion: ExportMajorVersion, MinorVersion: ExportMinorVersion, CreatedTime: time.Now()}
	exportedData.Data = make(map[string][]interface{})
	// ... and march through everything.
	exportedData.Data["client"] = client.ExportAllClients()
	exportedData.Data["cookbook"] = exportTransformSlice(cookbook.AllCookbooks())
	exportedData.Data["databag"] = exportTransformSlice(databag.AllDataBags())
	exportedData.Data["environment"] = exportTransformSlice(environment.AllEnvironments())
	exportedData.Data["filestore"] = exportTransformSlice(filestore.AllFilestores())
	exportedData.Data["loginfo"] = exportTransformSlice(loginfo.AllLogInfos())
	exportedData.Data["node"] = exportTransformSlice(node.AllNodes())
	exportedData.Data["node_status"] = exportTransformSlice(node.AllNodeStatuses())
	exportedData.Data["report"] = exportTransformSlice(report.AllReports())
	exportedData.Data["role"] = exportTransformSlice(role.AllRoles())
	exportedData.Data["sandbox"] = exportTransformSlice(sandbox.AllSandboxes())
	exportedData.Data["shovey"] = exportTransformSlice(shovey.AllShoveys())
	exportedData.Data["shovey_run"] = exportTransformSlice(shovey.AllShoveyRuns())
	exportedData.Data["shovey_run_stream"] = exportTransformSlice(shovey.AllShoveyRunStreams())
	exportedData.Data["user"] = user.ExportAllUsers()

	fp, err := os.Create(fileName)
	if err != nil {
		return err
	}
	enc := json.NewEncoder(fp)
	if err = enc.Encode(&exportedData); err != nil {
		return err
	}
	return nil
}
Ejemplo n.º 2
0
func (e *ChefEnvironment) cookbookList() []*cookbook.Cookbook {
	return cookbook.AllCookbooks()
}