ResolveAlias follows a one-hop alias to its target config. Returns (resolved, wasAlias, err). Non-alias configs return (cfg, false, nil) unchanged. Strict: the target must exist and must not itself be an alias (chains are rejected). The returned config is a copy of the target.
(cfg *ModelConfig)
| 299 | // unchanged. Strict: the target must exist and must not itself be an alias |
| 300 | // (chains are rejected). The returned config is a copy of the target. |
| 301 | func (bcl *ModelConfigLoader) ResolveAlias(cfg *ModelConfig) (*ModelConfig, bool, error) { |
| 302 | if cfg == nil || !cfg.IsAlias() { |
| 303 | return cfg, false, nil |
| 304 | } |
| 305 | target, exists := bcl.GetModelConfig(cfg.Alias) |
| 306 | if !exists { |
| 307 | return nil, true, fmt.Errorf("alias %q points to unknown model %q", cfg.Name, cfg.Alias) |
| 308 | } |
| 309 | if target.IsAlias() { |
| 310 | return nil, true, fmt.Errorf("alias %q points to another alias %q (chains are not allowed)", cfg.Name, cfg.Alias) |
| 311 | } |
| 312 | return &target, true, nil |
| 313 | } |
| 314 | |
| 315 | // ValidateAliasTarget checks an alias config's target at create/swap time: |
| 316 | // the target must exist, must not be an alias, and must not be disabled. |
no test coverage detected