You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: main.go
    path of file: ./repos/chaos-mesh/tools/schedule-migration
    
    the code of the file until where you have to start completion: // Copyright 2021 Chaos Mesh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you m
    
func transformChaosSpec(obj Object) yaml.MapSlice {
	var (
		newSpec        yaml.MapSlice
		containerNames []string
	)
	for _, kv := range obj.Spec {
		if kv.Key == "scheduler" {
			continue
		}

		if kv.Key == "containerName" {
			containerNames = append(containerNames, kv.Value.(string))
			continue
		}

		if obj.Kind == "DNSChaos" {
			// 'scope' is obsolete in v2.0, and instead with 'patterns'
			// if 'scope' is 'all', means chaos applies to all the host
			// so it equal to pattern "*". otherwise, can't transform.
			if kv.Key == "scope" && kv.Value == "all" {
				patterns := []string{"*"}
				kv = yaml.MapItem{Key: "patterns", Value: patterns}
			}
		}

		newSpec = append(newSpec, kv)
	}

	if len(containerNames) != 0 {
		newSpec = append(newSpec, yaml.MapItem{Key: "containerNames", Value: containerNames})
	}

	return newSpec
}