-
Notifications
You must be signed in to change notification settings - Fork 65
/
cookbook_artifacts.go
91 lines (83 loc) · 3.94 KB
/
cookbook_artifacts.go
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
package chef
import "fmt"
// CBAService is the service for interacting with chef server cookbook_artifacts endpoint
type CBAService struct {
client *Client
}
// CBAGetResponse is returned from the chef-server for Get Requests to /cookbook_artifacts
type CBAGetResponse map[string]CBA
type CBA struct {
Url string `json:"url,omitempty"`
CBAVersions []CBAVersion `json:"versions,omitempty"`
}
type CBAVersion struct {
Url string `json:"url,omitempty"`
Identifier string `json:"identifier,omitempty"`
}
// CBADetail represents the detail for a specific cookbook_artifact
type CBADetail struct {
Version string `json:"version"`
Name string `json:"name"`
Identifier string `json:"identifier"`
RootFiles []CookbookItem `json:"root_files,omitempty"`
Providers []CookbookItem `json:"providers,omitempty"`
Resources []CookbookItem `json:"resources,omitempty"`
Libraries []CookbookItem `json:"libraries,omitempty"`
Attributes []CookbookItem `json:"attributes,omitempty"`
Recipes []CookbookItem `json:"recipes,omitempty"`
Definitions []CookbookItem `json:"definitions,omitempty"`
Files []CookbookItem `json:"files,omitempty"`
Templates []CookbookItem `json:"templates,omitempty"`
Frozen bool `json:"frozen?,omitempty"`
ChefType string `json:"chef_type,omitempty"`
Metadata CBAMeta `json:"metadata,omitempty"`
}
// CBAMeta represents the cookbook_artifacts metadata information
type CBAMeta struct {
Name string `json:"name,omitempty"`
Version string `json:"version,omitempty"`
Description string `json:"description,omitempty"`
LongDescription string `json:"long_description,omitempty"`
Maintainer string `json:"maintainer,omitempty"`
MaintainerEmail string `json:"maintainer_email,omitempty"`
License string `json:"license,omitempty"`
Platforms map[string]string `json:"platforms,omitempty"`
Depends map[string]string `json:"dependencies,omitempty"`
Reccomends map[string]string `json:"recommendations,omitempty"`
Suggests map[string]string `json:"suggestions,omitempty"`
Conflicts map[string]string `json:"conflicting,omitempty"`
Provides map[string]string `json:"providing,omitempty"`
Replaces map[string]string `json:"replacing,omitempty"`
Attributes map[string]interface{} `json:"attributes,omitempty"`
Groupings map[string]interface{} `json:"groupings,omitempty"`
Recipes map[string]string `json:"recipes,omitempty"`
SourceURL string `json:"source_url,omitempty"`
IssuesURL string `json:"issues_url,omitempty"`
Privacy bool `json:"privacy,omitempty"`
ChefVersions [][]string `json:"chef_versions,omitempty"`
OhaiVersions []string `json:"ohai_versions,omitempty"`
Gems [][]string `json:"gems,omitempty"`
}
// List lists the Cookbook_Artifacts in the Chef server.
//
// GET /cookbook_artifacts
func (c *CBAService) List() (data CBAGetResponse, err error) {
err = c.client.magicRequestDecoder("GET", "cookbook_artifacts", nil, &data)
return
}
// Get returns details for a specific cookbook artifact
//
// GET /cookbook_artifacts/name
func (c *CBAService) Get(name string) (data CBAGetResponse, err error) {
path := fmt.Sprintf("cookbook_artifacts/%s", name)
err = c.client.magicRequestDecoder("GET", path, nil, &data)
return
}
// GetVersion fetches a specific version of a cookbook_artifact from the server api
//
// GET /cookbook_artifacts/foo/1ef062de1bc4cb14e4a78fb739e104eb9508473e
func (c *CBAService) GetVersion(name, id string) (data CBADetail, err error) {
url := fmt.Sprintf("cookbook_artifacts/%s/%s", name, id)
err = c.client.magicRequestDecoder("GET", url, nil, &data)
return
}