-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ignore input changes to username and password (#498)
* Intercept registry diff and handle its fields as a first pass at better diff * Return NONE for diffResponse if the only updates are to usernae or password * Separate out detailed diff functionality in separate function for unit test * Add unit test for diffUpdates * Add documentation * Typos in docs line Co-authored-by: Aaron Friel <[email protected]> * Regenerate schema and SDKs --------- Co-authored-by: Aaron Friel <[email protected]>
- Loading branch information
1 parent
4705df3
commit 1bd61e4
Showing
9 changed files
with
176 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
package provider | ||
|
||
import ( | ||
"github.com/pulumi/pulumi/sdk/v3/go/common/resource" | ||
rpc "github.com/pulumi/pulumi/sdk/v3/proto/go" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestDiffUpdates(t *testing.T) { | ||
|
||
t.Run("No diff happens on changed password", func(t *testing.T) { | ||
expected := map[string]*rpc.PropertyDiff{} | ||
input := map[resource.PropertyKey]resource.ValueDiff{ | ||
"registry": { | ||
Object: &resource.ObjectDiff{ | ||
Updates: map[resource.PropertyKey]resource.ValueDiff{"password": { | ||
Old: resource.PropertyValue{ | ||
V: "FancyToken", | ||
}, | ||
New: resource.PropertyValue{ | ||
V: "PedestrianPassword", | ||
}, | ||
Array: (*resource.ArrayDiff)(nil), | ||
Object: (*resource.ObjectDiff)(nil), | ||
}}, | ||
}, | ||
}, | ||
} | ||
actual := diffUpdates(input) | ||
assert.Equal(t, expected, actual) | ||
}) | ||
|
||
t.Run("No diff happens on changed username", func(t *testing.T) { | ||
expected := map[string]*rpc.PropertyDiff{} | ||
input := map[resource.PropertyKey]resource.ValueDiff{ | ||
"registry": { | ||
Object: &resource.ObjectDiff{ | ||
Updates: map[resource.PropertyKey]resource.ValueDiff{"username": { | ||
Old: resource.PropertyValue{ | ||
V: "platypus", | ||
}, | ||
New: resource.PropertyValue{ | ||
V: "Schnabeltier", | ||
}, | ||
Array: (*resource.ArrayDiff)(nil), | ||
Object: (*resource.ObjectDiff)(nil), | ||
}}, | ||
}, | ||
}, | ||
} | ||
actual := diffUpdates(input) | ||
assert.Equal(t, expected, actual) | ||
}) | ||
|
||
t.Run("Diff happens on changed server name", func(t *testing.T) { | ||
expected := map[string]*rpc.PropertyDiff{ | ||
"registry": { | ||
Kind: rpc.PropertyDiff_UPDATE, | ||
}, | ||
} | ||
input := map[resource.PropertyKey]resource.ValueDiff{ | ||
"registry": { | ||
Object: &resource.ObjectDiff{ | ||
Updates: map[resource.PropertyKey]resource.ValueDiff{"server": { | ||
Old: resource.PropertyValue{ | ||
V: "dockerhub", | ||
}, | ||
New: resource.PropertyValue{ | ||
V: "ShinyPrivateGHCR", | ||
}, | ||
Array: (*resource.ArrayDiff)(nil), | ||
Object: (*resource.ObjectDiff)(nil), | ||
}}, | ||
}, | ||
}, | ||
} | ||
actual := diffUpdates(input) | ||
assert.Equal(t, expected, actual) | ||
}) | ||
|
||
t.Run("Diff happens on changed build context", func(t *testing.T) { | ||
expected := map[string]*rpc.PropertyDiff{ | ||
"build": { | ||
Kind: rpc.PropertyDiff_UPDATE, | ||
}, | ||
} | ||
input := map[resource.PropertyKey]resource.ValueDiff{ | ||
"build": { | ||
Object: &resource.ObjectDiff{ | ||
Updates: map[resource.PropertyKey]resource.ValueDiff{"contextDigest": { | ||
Old: resource.PropertyValue{ | ||
V: "12345", | ||
}, | ||
New: resource.PropertyValue{ | ||
V: "54321", | ||
}, | ||
Array: (*resource.ArrayDiff)(nil), | ||
Object: (*resource.ObjectDiff)(nil), | ||
}}, | ||
}, | ||
}, | ||
} | ||
actual := diffUpdates(input) | ||
assert.Equal(t, expected, actual) | ||
}) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters