engine: resources: pkg: Implement the CompatibleRes interface

This signals to an interested consumer that two or more compatible
resources can be merged safely. This is so that we can avoid the
"duplicate resource" design problem that puppet had.

To test this, you can run:

./mgmt run --tmp-prefix lang --lang 'pkg "cowsay" { state => "installed", } pkg "cowsay" { state => "newest", }'

which should work.
This commit is contained in:
James Shubin
2018-12-29 02:47:38 -05:00
parent f10dddadd6
commit e3eefeb3fe
3 changed files with 160 additions and 0 deletions

View File

@@ -367,6 +367,29 @@ func TestAstFunc0(t *testing.T) {
// graph: graph,
// })
//}
// // FIXME: blocked by: https://github.com/purpleidea/mgmt/issues/199
//{
// graph, _ := pgraph.NewGraph("g")
// v1, v2 := vtex("str(cowsay)"), vtex("str(cowsay)")
// v3, v4 := vtex("str(installed)"), vtex("str(newest)")
//
// graph.AddVertex(&v1, &v2, &v3, &v4)
//
// testCases = append(testCases, test{
// name: "duplicate resource",
// code: `
// # these two are allowed because they are compatible
// pkg "cowsay" {
// state => "installed",
// }
// pkg "cowsay" {
// state => "newest",
// }
// `,
// fail: false,
// graph: graph,
// })
//}
{
testCases = append(testCases, test{
name: "variable re-declaration and type change error",