refactor(assistant): improve sandbox version extraction logic
- Enhanced the extractSandboxVersion function to support multiple input types, including *sandboxTypes.SandboxConfig and map[string]any, for better flexibility in version retrieval. - Simplified the version extraction process, ensuring consistent handling of sandbox configurations.
This commit is contained in:
parent
d43b637ad4
commit
96194110d1
1 changed files with 9 additions and 2 deletions
|
|
@ -1101,8 +1101,15 @@ func mergeSearchConfig(base, override *searchTypes.Config) *searchTypes.Config {
|
|||
|
||||
// extractSandboxVersion tries to read the "version" field from a sandbox config value.
|
||||
func extractSandboxVersion(v any) string {
|
||||
if m, ok := v.(map[string]any); ok {
|
||||
if ver, ok := m["version"].(string); ok {
|
||||
switch sb := v.(type) {
|
||||
case *sandboxTypes.SandboxConfig:
|
||||
if sb != nil {
|
||||
return sb.Version
|
||||
}
|
||||
case sandboxTypes.SandboxConfig:
|
||||
return sb.Version
|
||||
case map[string]any:
|
||||
if ver, ok := sb["version"].(string); ok {
|
||||
return ver
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue