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
// Difference returns the Current value of a Difference by key
func (t *Status) Difference(key string) (string, bool) {
diff, ok := t.Differences[key]
if !ok {
return "", ok
}
return diff.Current(), diff.Changes()
}
Usage would be like this in an Apply() phase to check if file content has been modified:
if content, ok := status.Difference("content"); ok && f.Type == "file" {
err = ioutil.WriteFile(f.Destination, content, f.FileMode)
As part of this, the engine and Check() should use the status.gostatus.AnyChanges() method.
This means that a typical check would just AddDifference() for every field, and AnyChanges() is used to see if any of the defined differences indicate a change.
Instead of doing this in my Check() method:
if f.State != actual.State {
status.AddDifference("state", actual.State, f.State, "")
}
👍 The docker container resource already follows the pattern of calling status.AddDifference without comparing first which mostly works today. But, other parts of the system need updating. For example, the printer doesn't check if the diffs have changes so you end up with output like described in #317 (comment).
Usage would be like this in an
Apply()
phase to check if file content has been modified:status.go
status.AnyChanges()
method.This means that a typical check would just
AddDifference()
for every field, andAnyChanges()
is used to see if any of the defined differences indicate a change.Instead of doing this in my Check() method:
I'd just do:
And expect anything else to call
AnyChanges()
for any change orDifference()
to get the value of a specific change.We'd have to be more aggressive about using
Default
values to fill in results whenOriginal
or Current is not defined.For example of default, take the example of permissions. The logic would be:
0750
The text was updated successfully, but these errors were encountered: