Beispiel #1
0
func (r *ResourcesSuite) Test_ParseResourcesJSON(c *C) {
	resources := puck.ParseResourcesJSON([]byte(r.configJSON))
	resource := resources.Resources[0]
	c.Check(resource.Type, Equals, "directory")
	c.Check(resource.NameAttribute, Equals, "/foo/bar")
	c.Check(resource.Attributes["recursive"], Equals, true)
	c.Check(resource.Attributes["action"], Equals, "create")
}
Beispiel #2
0
func resourcesHandler(w http.ResponseWriter, r *http.Request) {
	body, _ := ioutil.ReadAll(r.Body)
	resources := puck.ParseResourcesJSON(body)

	resourceStrings := puck.CompileChefResources(resources.Resources)
	chefApplyOutput := puck.RunChefApply(resourceStrings)

	w.Header().Set("Content-Type", "application/json")
	w.Write(chefApplyOutput)
}