loadDeleteConfig loads and merges configuration from JSON file and CLI flags
(cmd *cobra.Command)
| 1295 | containerEnv := make([]ContainerEnvironmentEntry, 0, len(values)) |
| 1296 | for _, env := range values { |
| 1297 | parts := strings.SplitN(env, "=", 2) |
| 1298 | if len(parts) != 2 { |
| 1299 | return nil, fmt.Errorf("invalid environment variable format '%s', expected 'key=value'", env) |
| 1300 | } |
| 1301 | containerEnv = append(containerEnv, ContainerEnvironmentEntry{ |
| 1302 | Key: parts[0], |
| 1303 | Value: parts[1], |
| 1304 | }) |
| 1305 | } |
| 1306 | return containerEnv, nil |
| 1307 | } |
| 1308 | |
| 1309 | func parsePerAccountPriorities(values []string) (map[string]uint32, error) { |
| 1310 | if len(values) > 64 { |
| 1311 | return nil, fmt.Errorf("at most 64 distinct NCA ID priority overrides are allowed") |
| 1312 | } |
| 1313 | |
| 1314 | overrides := make(map[string]uint32, len(values)) |
| 1315 | for _, value := range values { |
| 1316 | ncaID, priority, err := parsePerAccountPriority(value) |
| 1317 | if err != nil { |
| 1318 | return nil, fmt.Errorf("invalid per-account priority %q: %w", value, err) |
| 1319 | } |
| 1320 | if _, exists := overrides[ncaID]; exists { |
| 1321 | return nil, fmt.Errorf("duplicate per-account priority for NCA ID %q", ncaID) |
| 1322 | } |
| 1323 | overrides[ncaID] = priority |
| 1324 | } |
| 1325 | return overrides, nil |
| 1326 | } |
| 1327 | |
| 1328 | func parsePerAccountPriority(value string) (string, uint32, error) { |
| 1329 | ncaID, priorityText, found := strings.Cut(value, ":") |
| 1330 | ncaID = strings.TrimSpace(ncaID) |
| 1331 | priorityText = strings.TrimSpace(priorityText) |
| 1332 | if !found || ncaID == "" || priorityText == "" { |