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: container_ports.go
    path of file: ./repos/rancher/pkg/schemas/mapper
    
    the code of the file until where you have to start completion: package mapper

import (
	"strings"

	"github.com/rancher/norman/types"
	"github.com/rancher/norman/types/convert"
	"github.com/rancher/norman/types/mapper"
	"github.com/rancher/norman/types/values"
	"github.com/sirupsen/logrus"
)

type ContainerPorts struct {
}

func (n ContainerPorts) FromInternal(data map[string]interface{}) {
	field := mapper.AnnotationField{
		Field: "ports",
		List:  true,
	}
	field.FromInternal(data)

	containers := convert.ToInterfaceSlice(data["containers"])
	annotationPorts := convert.ToInterfaceSlice(data["ports"])
	annotationsPortsMap := map[string]map[string]interface{}{}

	// process fields defined via annotations
	for i := 0; i < le
    
func (n ContainerPorts) FromInternal(data map[string]interface{}) {
	field := mapper.AnnotationField{
		Field: "ports",
		List:  true,
	}
	field.FromInternal(data)

	containers := convert.ToInterfaceSlice(data["containers"])
	annotationPorts := convert.ToInterfaceSlice(data["ports"])
	annotationsPortsMap := map[string]map[string]interface{}{}

	// process fields defined via annotations
	for i := 0; i < len(annotationPorts) && i < len(containers); i++ {
		container := convert.ToMapInterface(containers[i])
		if container != nil {
			portsSlice := convert.ToInterfaceSlice(annotationPorts[i])
			portMap := map[string]interface{}{}
			for _, port := range portsSlice {
				asMap, err := convert.EncodeToMap(port)
				if err != nil {
					logrus.Warnf("Failed to convert container port to map %v", err)
					continue
				}
				asMap["type"] = "/v3/project/schemas/containerPort"
				name, _ := values.GetValue(asMap, "name")
				portMap[convert.ToString(name)] = asMap
			}
			containerName, _ := values.GetValue(container, "name")
			annotationsPortsMap[convert.ToString(containerName)] = portMap
		}
	}

	for _, container := range containers {
		// iterate over container ports and see if some of them are not defined via annotation
		// set kind to hostport if source port is set, and clusterip if it is not
		containerMap := convert.ToMapInterface(container)
		containerName, _ := values.GetValue(containerMap, "name")
		portMap := annotationsPortsMap[convert.ToString(containerName)]
		if portMap == nil {
			portMap = map[string]interface{}{}
		}
		var containerPorts []interface{}
		containerPortSlice := convert.ToInterfaceSlice(containerMap["ports"])
		for _, port := range containerPortSlice {
			asMap, err := convert.EncodeToMap(port)
			if err != nil {
				logrus.Warnf("Failed to convert container port to map %v", err)
				continue
			}
			portName, _ := values.GetValue(asMap, "name")
			if annotationPort, ok := portMap[convert.ToString(portName)]; ok {
				containerPorts = append(containerPorts, annotationPort)
			} else {
				hostPort, _ := values.GetValue(asMap, "hostPort")
				if hostPort == nil {
					asMap["kind"] = "ClusterIP"
				} else {
					asMap["sourcePort"] = hostPort
					asMap["kind"] = "HostPort"
				}
				containerPorts = append(containerPorts, asMap)
			}
		}
		containerMap["ports"] = containerPorts
	}

}