Instead of requiring a plugin host for package loading in the HCL2 binder, define a much narrower interface that exposes the ability to fetch the schema for a package at a specific version. This interface is defined in the schema package, which also exposes a caching loader that is backed by provider plugins. These changes also add some convenience methods to `*schema.Package` for fast access to particular resources and functions. Related to #1635.
18 lines
435 B
Go
18 lines
435 B
Go
package hcl2
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/pulumi/pulumi/pkg/v2/codegen/internal/test"
|
|
"github.com/pulumi/pulumi/pkg/v2/codegen/schema"
|
|
"github.com/pulumi/pulumi/sdk/v2/go/common/util/contract"
|
|
)
|
|
|
|
func BenchmarkLoadPackage(b *testing.B) {
|
|
loader := schema.NewPluginLoader(test.NewHost(testdataPath))
|
|
|
|
for n := 0; n < b.N; n++ {
|
|
_, err := NewPackageCache().loadPackageSchema(loader, "aws")
|
|
contract.AssertNoError(err)
|
|
}
|
|
}
|