/usr/share/gocode/src/github.com/go-chef/chef/role.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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | package chef
import "fmt"
type RoleService struct {
client *Client
}
type RoleListResult map[string]string
type RoleCreateResult map[string]string
// Role represents the native Go version of the deserialized Role type
type Role struct {
Name string `json:"name"`
ChefType string `json:"chef_type"`
Description string `json:"description"`
RunList RunList `json:"run_list"`
DefaultAttributes interface{} `json:"default_attributes,omitempty"`
OverrideAttributes interface{} `json:"override_attributes,omitempty"`
JsonClass string `json:"json_class,omitempty"`
}
// String makes RoleListResult implement the string result
func (e RoleListResult) String() (out string) {
return strMapToStr(e)
}
// String makes RoleCreateResult implement the string result
func (e RoleCreateResult) String() (out string) {
return strMapToStr(e)
}
// List lists the roles in the Chef server.
//
// Chef API docs: http://docs.getchef.com/api_chef_server.html#id31
func (e *RoleService) List() (data *RoleListResult, err error) {
err = e.client.magicRequestDecoder("GET", "roles", nil, &data)
return
}
// Create a new role in the Chef server.
//
// Chef API docs: http://docs.getchef.com/api_chef_server.html#id32
func (e *RoleService) Create(role *Role) (data *RoleCreateResult, err error) {
// err = e.client.magicRequestDecoder("POST", "roles", role, &data)
body, err := JSONReader(role)
if err != nil {
return
}
// BUG(fujiN): This is now both a *response* decoder and handles upload.. gettin smelly
err = e.client.magicRequestDecoder(
"POST",
"roles",
body,
&data,
)
return
}
// Delete a role from the Chef server.
//
// Chef API docs: http://docs.getchef.com/api_chef_server.html#id33
func (e *RoleService) Delete(name string) (err error) {
path := fmt.Sprintf("roles/%s", name)
err = e.client.magicRequestDecoder("DELETE", path, nil, nil)
return
}
// Get gets a role from the Chef server.
//
// Chef API docs: http://docs.getchef.com/api_chef_server.html#id34
func (e *RoleService) Get(name string) (data *Role, err error) {
path := fmt.Sprintf("roles/%s", name)
err = e.client.magicRequestDecoder("GET", path, nil, &data)
return
}
// Update a role in the Chef server.
//
// Chef API docs: http://docs.getchef.com/api_chef_server.html#id35
func (e *RoleService) Put(role *Role) (data *Role, err error) {
path := fmt.Sprintf("roles/%s", role.Name)
// err = e.client.magicRequestDecoder("PUT", path, role, nil)
body, err := JSONReader(role)
if err != nil {
return
}
err = e.client.magicRequestDecoder(
"PUT",
path,
body,
&data,
)
return
}
// Get a list of environments have have environment specific run-lists for the given role
//
// Chef API docs: http://docs.getchef.com/api_chef_server.html#id36
// Get the environment-specific run-list for a role
//
// Chef API docs: http://docs.getchef.com/api_chef_server.html#id37
|