Assemble collection resources by qualified ID

This commit is contained in:
2026-10-17 06:03:28 +00:00
parent a10a9053b7
commit 473fc1f6d7
12 changed files with 387 additions and 154 deletions

View File

@@ -38,3 +38,27 @@ func resourceNamespaceFromID(id string) (string, bool) {
namespace, _, _ := strings.Cut(id, "/")
return namespace, true
}
// IsValidResourceID reports whether id is an unqualified resource ID or one
// valid namespace/local-ID pair.
func IsValidResourceID(id string) bool { return validResourceID(id) }
// IsValidResourceNamespace reports whether namespace is nonblank and contains
// no namespace separator.
func IsValidResourceNamespace(namespace string) bool { return validResourceNamespace(namespace) }
// IsValidLocalResourceKey reports whether key is a nonblank key for a
// namespace-local resource mapping.
func IsValidLocalResourceKey(key string) bool { return validLocalResourceKey(key) }
// QualifyLocalResourceID combines a validated namespace and local mapping key.
// An empty namespace leaves a valid unqualified key unchanged.
func QualifyLocalResourceID(namespace, key string) (string, bool) {
if !validLocalResourceKey(key) || (namespace != "" && !validResourceNamespace(namespace)) {
return "", false
}
if namespace == "" {
return key, true
}
return namespace + "/" + key, true
}