refact(target): Switch subtype attributes to oneof

This updates the target resources to use a oneof for attributes. This
allows requests to the targets service to leverage the new
subtypes.AttributeTransformerInterceptor so that attributes are strongly
typed prior to the service handler.
This commit is contained in:
Timothy Messier authored and Johan Brandhorst-Satzkorn committed 2022-04-20 13:32:32 -04:00
1 parent 8c452b0991
commit c8be4a9890
10 files changed
+483 -406

No files matched your search

@@ -70,6 +70,22 @@ func (r *registry) subtypeFromId(domain, id string) Subtype {
return subtype
}
func (r *registry) prefixes(domain string) []string {
r.RLock()
defer r.RUnlock()
subtypePrefixes, ok := r.subtypesPrefixes[domain]
if !ok {
return nil
}
ret := make([]string, 0, len(subtypePrefixes))
for p := range subtypePrefixes {
ret = append(ret, p)
}
return ret
}
// 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.
@@ -123,6 +139,11 @@ func SubtypeFromId(domain, id string) Subtype {
return globalRegistry.subtypeFromId(domain, id)
}
// Prefixes returns the list of all known Prefixes for a domain.
func Prefixes(domain string) []string {
return globalRegistry.prefixes(domain)
}
// 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.