func ServicePorts(srvcPorts []interface{}) []api.ServicePort { if len(srvcPorts) == 0 { return nil } var ports []api.ServicePort for _, p := range srvcPorts { userPort := p.(map[string]interface{}) srvcPort := api.ServicePort{} if _, ok := userPort["name"]; ok { srvcPort.Name = userPort["name"].(string) } if _, ok := userPort["protocol"]; ok { srvcPort.Protocol = api.Protocol(userPort["protocol"].(string)) } if _, ok := userPort["port"]; ok { srvcPort.Port = userPort["port"].(int) } if _, ok := userPort["node_port"]; ok { srvcPort.NodePort = userPort["node_port"].(int) } ports = append(ports, srvcPort) } return ports }