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
+102Lines changed: 102 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,108 @@ See also: `#addition?`, `#change?`, `#removal?`
28
28
29
29
Note: Internally `~` and `!` represent different types of changes, but when presenting the output, these can generally be considered equivalent.
30
30
31
+
#### `#new_value` (Object)
32
+
33
+
Returns the value of the resource from the new catalog.
34
+
35
+
- If a resource was added, this returns the data structure associated with the resource in the Puppet catalog. For example, if the resource was created as follows in the Puppet catalog, the `new_value` is as indicated.
- If a resource was removed, this returns `nil` because there was no value of this resource in the new catalog.
53
+
54
+
- If a resource was changed, this returns the portion of the data structure that is indicated by the `.structure` method. For example, if the resource existed as follows in both the old and new Puppet catalogs, the `new_value` is as indicated.
55
+
56
+
```
57
+
# Resource in Old Catalog
58
+
{
59
+
"type": "File",
60
+
"title": "/etc/foo",
61
+
"parameters": {
62
+
"owner": "root",
63
+
"content": "This is the old file"
64
+
}
65
+
}
66
+
67
+
# Resource in New Catalog
68
+
{
69
+
"type": "File",
70
+
"title": "/etc/foo",
71
+
"parameters": {
72
+
"owner": "root",
73
+
"content": "This is the NEW FILE!!!!!"
74
+
}
75
+
}
76
+
77
+
# Demonstrates structure and old_value
78
+
diff.structure #=> ['parameters', 'content']
79
+
diff.old_value #=> 'This is the NEW FILE!!!!!'
80
+
```
81
+
82
+
#### `#old_value` (Object)
83
+
84
+
Returns the value of the resource from the old catalog.
85
+
86
+
- If a resource was added, this returns `nil` because there was no value of this resource in the old catalog.
87
+
88
+
- If a resource was removed, this returns the data structure associated with the resource in the Puppet catalog. For example, if the resource existed as follows in the Puppet catalog, the `old_value` is as indicated.
- If a resource was changed, this returns the portion of the data structure that is indicated by the `.structure` method. For example, if the resource existed as follows in both the old and new Puppet catalogs, the `old_value` is as indicated.
106
+
107
+
```
108
+
# Resource in Old Catalog
109
+
{
110
+
"type": "File",
111
+
"title": "/etc/foo",
112
+
"parameters": {
113
+
"owner": "root",
114
+
"content": "This is the old file"
115
+
}
116
+
}
117
+
118
+
# Resource in New Catalog
119
+
{
120
+
"type": "File",
121
+
"title": "/etc/foo",
122
+
"parameters": {
123
+
"owner": "root",
124
+
"content": "This is the NEW FILE!!!!!"
125
+
}
126
+
}
127
+
128
+
# Demonstrates structure and old_value
129
+
diff.structure #=> ['parameters', 'content']
130
+
diff.old_value #=> 'This is the old file'
131
+
```
132
+
31
133
#### `#removal?` (Boolean)
32
134
33
135
Returns true if this diff is a removal (resource exists in old catalog but not new catalog).
0 commit comments