You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is only applicable for catalogs compiled by `OctocatalogDiff::Catalog::Computed`. This method will return `nil` for catalogs generated by other backends.
30
+
17
31
#### `#error_message` (String)
18
32
33
+
Returns the error message for a failed catalog. (If the catalog is valid, this returns `nil`.)
34
+
35
+
```
36
+
good_catalog.valid? #=> true
37
+
good_catalog.error_message #=> nil
38
+
39
+
bad_catalog.valid? #=> false
40
+
bad_catalog.error_message #=> 'Failed to compile catalog for node ...'
41
+
```
42
+
19
43
#### `#puppet_version` (String)
20
44
21
-
#### `#resource(<Hash>)` (Object)
45
+
Returns the Puppet version used to compile the catalog.
46
+
47
+
```
48
+
catalog.puppet_version #=> '3.8.7'
49
+
```
50
+
51
+
This is only applicable for catalogs compiled by `OctocatalogDiff::Catalog::Computed`. This method will return `nil` for catalogs generated by other backends.
52
+
53
+
#### `#resource(<Hash>)` (Hash)
54
+
55
+
Returns the hash representation of the object identified by the type and title supplied.
56
+
57
+
This method requires 1 argument, which is a hash containing `:type` and `:title` keys.
58
+
59
+
```
60
+
catalog.resource(type: 'File', title: '/etc/foo')
61
+
#=> {"title"=>"/etc/foo", "type"=>"File",
62
+
"parameters"=>{"content"=>"This is the file", "owner"=>"root"},
Returns `nil` if the type+title resource was not present in the catalog.
22
67
23
-
#### `#resources` (Array<Object>)
68
+
##### Notes
69
+
70
+
1. The first call to this method will build a hash table (`O(N)` operation) from the resource array. Thereafter, each call to this method will look up the value in that hash table (`O(1)` operation). To perform lookups of known types and titles, it is faster to use this method than to use `#resources` with array operations when performing multiple lookups.
71
+
72
+
2. The structure of the returned hash is dependent on the representation of the resource in the Puppet catalog. It is therefore possible that different versions of Puppet could cause different data structures. It is the author's experience that Puppet 3.8.7 and Puppet 4.x produce similar (if not indistinguishable) resource representations.
73
+
74
+
3. This method will also locate a resource that was named using an alias.
75
+
76
+
```
77
+
# Puppet code
78
+
file { '/etc/foo':
79
+
alias => 'foo file for the win',
80
+
...
81
+
}
82
+
83
+
# octocatalog-diff API
84
+
catalog.resource(type: 'File', title: 'foo file for the win')
85
+
#=> {"title"=>"/etc/foo", "type"=>"File", ...}
86
+
```
87
+
88
+
#### `#resources` (Array<Hash>)
89
+
90
+
Returns an array of catalog resources in a successful catalog. (If the catalog is not valid, this returns `nil`.)
91
+
92
+
```
93
+
bad_catalog.valid? #=> false
94
+
bad_catalog.resources #=> nil
95
+
96
+
good_catalog.valid? #=> true
97
+
good_catalog.resources
98
+
#=> [
99
+
{ "title"=>"/etc/foo", "type"=>"File", ... },
100
+
{ "title"=>"/bin/true", "type"=>"Exec", ... }
101
+
]
102
+
```
103
+
104
+
The structure of the returned hash is dependent on the representation of the resource in the Puppet catalog. It is therefore possible that different versions of Puppet could cause different data structures. It is the author's experience that Puppet 3.8.7 and Puppet 4.x produce similar (if not indistinguishable) resource representations.
24
105
25
106
#### `#to_json` (String)
26
107
108
+
Returns the JSON representation of a successful catalog. (If the catalog is not valid, this returns `nil`.)
0 commit comments