This adds a new requirement onto subtypes to register a NewFunc. Previously the subtypes where implementing this function anyway, but the target package was not including them in the registry. This resulted in packages that use the target package needing to import the subtypes directly, which we want to avoid. This refactor will require the subtypes to register their NewFunc which can then be used by `target.New` so packages that need to create targets can do so by only using the target package. This also updates the tcp subpackage to register a NewFunc.
20 lines
543 B
Go
20 lines
543 B
Go
package tcp
|
|
|
|
import "github.com/hashicorp/boundary/internal/target"
|
|
|
|
// Expose functions and variables for tests.
|
|
var (
|
|
TestId = testId
|
|
TestTargetName = testTargetName
|
|
DefaultTableName = defaultTableName
|
|
)
|
|
|
|
// NewTestTarget is a test helper that bypasses the scopeId checks
|
|
// performed by NewTarget, allowing tests to create Targets with
|
|
// nil scopeIds for more robust testing.
|
|
func NewTestTarget(scopeId string, opt ...target.Option) target.Target {
|
|
t, _ := newTarget("testScope", opt...)
|
|
t.SetScopeId(scopeId)
|
|
return t
|
|
}
|