2020-08-19 10:51:15 -07:00
|
|
|
package host
|
|
|
|
|
|
2021-07-27 09:59:52 -07:00
|
|
|
import "github.com/hashicorp/boundary/internal/types/subtypes"
|
2020-08-19 10:51:15 -07:00
|
|
|
|
2021-07-27 09:59:52 -07:00
|
|
|
var registry = subtypes.NewRegistry()
|
2020-08-19 10:51:15 -07:00
|
|
|
|
2021-07-27 09:59:52 -07:00
|
|
|
// SubtypeFromType returns the Subtype from the provided string or if
|
|
|
|
|
// no Subtype was registered with that string Unknown is returned.
|
|
|
|
|
func SubtypeFromType(t string) subtypes.Subtype {
|
|
|
|
|
return registry.SubtypeFromType(t)
|
2020-08-19 10:51:15 -07:00
|
|
|
}
|
|
|
|
|
|
2021-07-27 09:59:52 -07:00
|
|
|
// SubtypeFromId returns the Subtype from the provided id if the id's prefix
|
|
|
|
|
// was registered with a Subtype. Otherwise Unknown is returned.
|
|
|
|
|
func SubtypeFromId(id string) subtypes.Subtype {
|
|
|
|
|
return registry.SubtypeFromId(id)
|
2020-08-19 10:51:15 -07:00
|
|
|
}
|
|
|
|
|
|
2021-07-27 09:59:52 -07:00
|
|
|
// Register registers all the prefixes for a provided Subtype. Register returns
|
|
|
|
|
// an error if the subtype has already been registered or if any of the
|
|
|
|
|
// prefixes are associated with another subtype.
|
|
|
|
|
func Register(subtype subtypes.Subtype, prefixes ...string) error {
|
|
|
|
|
return registry.Register(subtype, prefixes...)
|
2020-08-19 10:51:15 -07:00
|
|
|
}
|