mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 01:41:48 -06:00
cb2e9119aa
Signed-off-by: namgyalangmo <75657887+namgyalangmo@users.noreply.github.com>
25 lines
887 B
Go
25 lines
887 B
Go
// Copyright (c) The OpenTofu Authors
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
// Copyright (c) 2023 HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package provisioners
|
|
|
|
// Factory is a function type that creates a new instance of a resource
|
|
// provisioner, or returns an error if that is impossible.
|
|
type Factory func() (Interface, error)
|
|
|
|
// FactoryFixed is a helper that creates a Factory that just returns some given
|
|
// single provisioner.
|
|
//
|
|
// Unlike usual factories, the exact same instance is returned for each call
|
|
// to the factory and so this must be used in only specialized situations where
|
|
// the caller can take care to either not mutate the given provider at all
|
|
// or to mutate it in ways that will not cause unexpected behavior for others
|
|
// holding the same reference.
|
|
func FactoryFixed(p Interface) Factory {
|
|
return func() (Interface, error) {
|
|
return p, nil
|
|
}
|
|
}
|