コード例 #1
0
ファイル: helper.go プロジェクト: polydawn/hroot
//Prepare the hroot output
func (d *Hroot) PrepareOutput() {
	switch d.dest.scheme {
	case "graph":
		//Look up the graph, and clear any unwanted state
		d.dest.graph = dex.NewGraph(d.folders.Graph)

		//If the user's git config isn't ready, we want to tell them *before* building.
		if !d.dest.graph.IsConfigReady() {
			ExitGently("\n" +
				"Git could not find a user name & email." + "\n" +
				"You'll need to set up git with the following commands:" + "\n\n" +
				"git config --global user.email \"[email protected]\"" + "\n" +
				"git config --global user.name \"Your Name\"")
		}

		//Cleanse the graph unless it'd be redundant.
		Println("Opening destination repository")
	case "file":
		//If the user did not specify an image path, set one
		if d.dest.path == "" {
			d.dest.path = "./image.tar"
		}

		//If the user is insane and wants to overwrite his source tar, stop him.
		//	Not at all robust (absolute paths? what are those? etc)
		if d.source.scheme == "file" && d.source.path == d.dest.path {
			ExitGently("Tar location is same for source and destination:", d.source.path)
		}
	case "index":
		ExitGently("Destination", d.dest.scheme, "is not supported yet.")
	}
}
コード例 #2
0
ファイル: helper.go プロジェクト: polydawn/hroot
//Prepare the hroot input
func (d *Hroot) PrepareInput() {

	//If you're using an index key with a non-index source, or upstream key with index source, reject.
	//Runs here (not LoadHroot) so commands have a chance to change settings.
	if d.source.scheme == "index" && d.image.Index == "" {
		ExitGently("You asked to pull from the index but have no index key configured.")
	} else if d.source.scheme != "index" && d.image.Upstream == "" {
		if d.source.scheme == "docker" {
			Println("Running an index image from docker cache.")
		} else {
			ExitGently("You asked to run from from", d.source.scheme, "but have no upstream key configured.")
		}
	}

	switch d.source.scheme {
	case "graph":
		//Look up the graph, and clear any unwanted state
		d.source.graph = dex.NewGraph(d.folders.Graph)
		Println("Opening source repository")
	case "file":
		//If the user did not specify an image path, set one
		if d.source.path == "" {
			d.source.path = "./image.tar"
		}
	case "index":
		//If pulling from the index, use the index key instead (protect URL namespace from docker)
		d.launchImage = d.image.Index
	}
}