Merge user bulk commands to the default one

This commit is contained in:
volodymyr 2025-05-31 21:01:17 +03:00
parent bedde4a037
commit 3e5e661646

View file

@ -577,10 +577,28 @@ func loadUserConfig(configDir string, base *UserConfig) (*UserConfig, error) {
return nil, err
}
if err := yaml.Unmarshal(content, base); err != nil {
tempConfig := &UserConfig{}
if err := yaml.Unmarshal(content, tempConfig); err != nil {
return nil, err
}
// Merge bulk commands instead of replacing them
if len(tempConfig.BulkCommands.Services) > 0 {
base.BulkCommands.Services = append(base.BulkCommands.Services, tempConfig.BulkCommands.Services...)
}
if len(tempConfig.BulkCommands.Containers) > 0 {
base.BulkCommands.Containers = append(base.BulkCommands.Containers, tempConfig.BulkCommands.Containers...)
}
if len(tempConfig.BulkCommands.Images) > 0 {
base.BulkCommands.Images = append(base.BulkCommands.Images, tempConfig.BulkCommands.Images...)
}
if len(tempConfig.BulkCommands.Volumes) > 0 {
base.BulkCommands.Volumes = append(base.BulkCommands.Volumes, tempConfig.BulkCommands.Volumes...)
}
if len(tempConfig.BulkCommands.Networks) > 0 {
base.BulkCommands.Networks = append(base.BulkCommands.Networks, tempConfig.BulkCommands.Networks...)
}
return base, nil
}