mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Go 1.19's "fmt" has some awareness of the new doc comment formatting conventions and adjusts the presentation of the source comments to make it clearer how godoc would interpret them. Therefore this commit includes various updates made by "go fmt" to acheve that. In line with our usual convention that we make stylistic/grammar/spelling tweaks typically only when we're "in the area" changing something else anyway, I also took this opportunity to review most of the comments that this updated to see if there were any other opportunities to improve them.
84 lines
2.5 KiB
Go
84 lines
2.5 KiB
Go
package terraform
|
|
|
|
import (
|
|
"github.com/zclconf/go-cty/cty"
|
|
|
|
"github.com/hashicorp/terraform/internal/addrs"
|
|
"github.com/hashicorp/terraform/internal/configs/configschema"
|
|
"github.com/hashicorp/terraform/internal/providers"
|
|
"github.com/hashicorp/terraform/internal/provisioners"
|
|
)
|
|
|
|
// simpleMockPluginLibrary returns a plugin library pre-configured with
|
|
// one provider and one provisioner, both called "test".
|
|
//
|
|
// The provider is built with simpleMockProvider and the provisioner with
|
|
// simpleMockProvisioner, and all schemas used in both are as built by
|
|
// function simpleTestSchema.
|
|
//
|
|
// Each call to this function produces an entirely-separate set of objects,
|
|
// so the caller can feel free to modify the returned value to further
|
|
// customize the mocks contained within.
|
|
func simpleMockPluginLibrary() *contextPlugins {
|
|
// We create these out here, rather than in the factory functions below,
|
|
// because we want each call to the factory to return the _same_ instance,
|
|
// so that test code can customize it before passing this component
|
|
// factory into real code under test.
|
|
provider := simpleMockProvider()
|
|
provisioner := simpleMockProvisioner()
|
|
ret := &contextPlugins{
|
|
providerFactories: map[addrs.Provider]providers.Factory{
|
|
addrs.NewDefaultProvider("test"): func() (providers.Interface, error) {
|
|
return provider, nil
|
|
},
|
|
},
|
|
provisionerFactories: map[string]provisioners.Factory{
|
|
"test": func() (provisioners.Interface, error) {
|
|
return provisioner, nil
|
|
},
|
|
},
|
|
}
|
|
ret.init() // prepare the internal cache data structures
|
|
return ret
|
|
}
|
|
|
|
// simpleTestSchema returns a block schema that contains a few optional
|
|
// attributes for use in tests.
|
|
//
|
|
// The returned schema contains the following optional attributes:
|
|
//
|
|
// - test_string, of type string
|
|
// - test_number, of type number
|
|
// - test_bool, of type bool
|
|
// - test_list, of type list(string)
|
|
// - test_map, of type map(string)
|
|
//
|
|
// Each call to this function produces an entirely new schema instance, so
|
|
// callers can feel free to modify it once returned.
|
|
func simpleTestSchema() *configschema.Block {
|
|
return &configschema.Block{
|
|
Attributes: map[string]*configschema.Attribute{
|
|
"test_string": {
|
|
Type: cty.String,
|
|
Optional: true,
|
|
},
|
|
"test_number": {
|
|
Type: cty.Number,
|
|
Optional: true,
|
|
},
|
|
"test_bool": {
|
|
Type: cty.Bool,
|
|
Optional: true,
|
|
},
|
|
"test_list": {
|
|
Type: cty.List(cty.String),
|
|
Optional: true,
|
|
},
|
|
"test_map": {
|
|
Type: cty.Map(cty.String),
|
|
Optional: true,
|
|
},
|
|
},
|
|
}
|
|
}
|