resolveDeclaredServiceMethodScopes returns the scopes declared by a service/resource/method command. It reconstructs the catalog path from the command ancestry and resolves it through the same navigation Module the command tree is built from (apicatalog), so it stays correct for nested resources ins
(cmd *cobra.Command, identity string)
| 99 | // Non-method commands (services, resources, shortcuts) resolve to a non-method |
| 100 | // target and yield no scopes. |
| 101 | func resolveDeclaredServiceMethodScopes(cmd *cobra.Command, identity string) []string { |
| 102 | if cmd == nil || strings.HasPrefix(cmd.Name(), "+") { |
| 103 | return nil |
| 104 | } |
| 105 | path := commandCatalogPath(cmd) |
| 106 | if len(path) == 0 { |
| 107 | return nil |
| 108 | } |
| 109 | target, err := registry.RuntimeCatalog().Resolve(path) |
| 110 | if err != nil || target.Kind != apicatalog.TargetMethod { |
| 111 | return nil |
| 112 | } |
| 113 | return registry.DeclaredScopesForMethod(target.Method.Method, identity) |
| 114 | } |
| 115 | |
| 116 | // commandCatalogPath reconstructs the catalog path [service, resource..., method] |
| 117 | // from a command's ancestry, excluding the root command. It is the inverse of |
no test coverage detected