AddDefaultToolset removes the default toolset and expands it to the actual default toolset IDs
(result []string)
| 418 | |
| 419 | // AddDefaultToolset removes the default toolset and expands it to the actual default toolset IDs |
| 420 | func AddDefaultToolset(result []string) []string { |
| 421 | hasDefault := false |
| 422 | seen := make(map[string]bool) |
| 423 | for _, toolset := range result { |
| 424 | seen[toolset] = true |
| 425 | if toolset == string(ToolsetMetadataDefault.ID) { |
| 426 | hasDefault = true |
| 427 | } |
| 428 | } |
| 429 | |
| 430 | // Only expand if "default" keyword was found |
| 431 | if !hasDefault { |
| 432 | return result |
| 433 | } |
| 434 | |
| 435 | result = RemoveToolset(result, string(ToolsetMetadataDefault.ID)) |
| 436 | |
| 437 | // Get default toolset IDs from the Inventory |
| 438 | // Build() can only fail if WithTools specifies invalid tools - not used here |
| 439 | r, _ := NewInventory(stubTranslator).Build() |
| 440 | for _, id := range r.DefaultToolsetIDs() { |
| 441 | if !seen[string(id)] { |
| 442 | result = append(result, string(id)) |
| 443 | } |
| 444 | } |
| 445 | return result |
| 446 | } |
| 447 | |
| 448 | func RemoveToolset(tools []string, toRemove string) []string { |
| 449 | result := make([]string, 0, len(tools)) |