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
Copy file name to clipboardExpand all lines: doc/dev/api/v1/objects/diff.md
+79-1Lines changed: 79 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,8 +24,86 @@ Returns the change type of the diff, which is one of the following characters:
24
24
-`-` for removal (resource exists in old catalog but not new catalog)
25
25
-`~` or `!` for change (resource exists in both catalogs but is different between them)
26
26
27
+
See also: `#addition?`, `#change?`, `#removal?`
28
+
27
29
Note: Internally `~` and `!` represent different types of changes, but when presenting the output, these can generally be considered equivalent.
28
30
29
-
#### `removal?` (Boolean)
31
+
#### `#removal?` (Boolean)
30
32
31
33
Returns true if this diff is a removal (resource exists in old catalog but not new catalog).
34
+
35
+
#### `#structure` (Array)
36
+
37
+
Returns the structure that has been changed, as an array.
38
+
39
+
When a resource was added or removed, the result is an empty array. That's because all of the parameters and other metadata from the resource exist entirely in one catalog but not the other.
40
+
41
+
When a resource has changed, one diff is created for each parameter that changed. For example, both the old and new catalogs contain the file resource `/etc/foo` but just the content has changed:
42
+
43
+
```
44
+
# Old
45
+
file { '/etc/foo':
46
+
owner => 'root',
47
+
content => 'This is the old file',
48
+
}
49
+
50
+
# New
51
+
file { '/etc/foo':
52
+
owner => 'root',
53
+
content => 'This is the NEW FILE!!!!!',
54
+
}
55
+
```
56
+
57
+
Internally, the Puppet catalog for this resource will look like this in the catalogs (this has been abbreviated a bit for clarity):
58
+
59
+
```
60
+
# Old
61
+
{
62
+
"type": "File",
63
+
"title": "/etc/foo",
64
+
"exported": false,
65
+
"parameters": {
66
+
"owner": "root",
67
+
"content": "This is the old file"
68
+
}
69
+
}
70
+
71
+
# New
72
+
{
73
+
"type": "File",
74
+
"title": "/etc/foo",
75
+
"exported": false,
76
+
"parameters": {
77
+
"owner": "root",
78
+
"content": "This is the NEW FILE!!!!!"
79
+
}
80
+
}
81
+
```
82
+
83
+
One diff will be generated to represent the change to the content of the file (which in the catalog is nested in the 'parameters' hash). The diff will be structured as follows:
84
+
85
+
```
86
+
diff.type #=> 'File'
87
+
diff.title #=> '/etc/foo'
88
+
diff.structure #=> ['parameters', 'content']
89
+
```
90
+
91
+
#### `#title` (String)
92
+
93
+
Returns the title of the resource from the Puppet catalog.
94
+
95
+
For example, a diff involving `File['/etc/passwd']` would have:
96
+
97
+
-`diff.title #=> '/etc/passwd'`
98
+
-`diff.type #=> 'File`
99
+
100
+
#### `#type` (String)
101
+
102
+
Returns the type of the resource from the Puppet catalog.
103
+
104
+
For example, a diff involving `File['/etc/passwd']` would have:
105
+
106
+
-`diff.title #=> '/etc/passwd'`
107
+
-`diff.type #=> 'File`
108
+
109
+
Note that the type will be capitalized because Puppet capitalizes this in catalogs.
0 commit comments