/usr/share/gocode/src/github.com/go-chef/chef/node.go is in golang-github-go-chef-chef-dev 0.0.1+git20161023.60.deb8c38-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | package chef
import "fmt"
type NodeService struct {
client *Client
}
// Node represents the native Go version of the deserialized Node type
type Node struct {
Name string `json:"name"`
Environment string `json:"chef_environment,omitempty"`
ChefType string `json:"chef_type,omitempty"`
AutomaticAttributes map[string]interface{} `json:"automatic,omitempty"`
NormalAttributes map[string]interface{} `json:"normal,omitempty"`
DefaultAttributes map[string]interface{} `json:"default,omitempty"`
OverrideAttributes map[string]interface{} `json:"override,omitempty"`
JsonClass string `json:"json_class,omitempty"`
RunList []string `json:"run_list,omitempty"`
}
type NodeResult struct {
Uri string `json:"uri"`
}
// NewNode is the Node constructor method
func NewNode(name string) (node Node) {
node = Node{
Name: name,
Environment: "_default",
ChefType: "node",
JsonClass: "Chef::Node",
}
return
}
// List lists the nodes in the Chef server.
//
// Chef API docs: http://docs.opscode.com/api_chef_server.html#id25
func (e *NodeService) List() (data map[string]string, err error) {
err = e.client.magicRequestDecoder("GET", "nodes", nil, &data)
return
}
// Get gets a node from the Chef server.
//
// Chef API docs: http://docs.opscode.com/api_chef_server.html#id28
func (e *NodeService) Get(name string) (node Node, err error) {
url := fmt.Sprintf("nodes/%s", name)
err = e.client.magicRequestDecoder("GET", url, nil, &node)
return
}
// Post creates a Node on the chef server
//
// Chef API docs: https://docs.getchef.com/api_chef_server.html#id39
func (e *NodeService) Post(node Node) (data *NodeResult, err error) {
body, err := JSONReader(node)
if err != nil {
return
}
err = e.client.magicRequestDecoder("POST", "nodes", body, &data)
return
}
// Put updates a node on the Chef server.
//
// Chef API docs: http://docs.getchef.com/api_chef_server.html#id42
func (e *NodeService) Put(n Node) (node Node, err error) {
url := fmt.Sprintf("nodes/%s", n.Name)
body, err := JSONReader(n)
if err != nil {
return
}
err = e.client.magicRequestDecoder("PUT", url, body, &node)
return
}
// Delete removes a node on the Chef server
//
// Chef API docs: https://docs.getchef.com/api_chef_server.html#id40
func (e *NodeService) Delete(name string) (err error) {
err = e.client.magicRequestDecoder("DELETE", "nodes/"+name, nil, nil)
return
}
|