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

import (
	"context"
	"reflect"

	"k8s.io/apimachinery/pkg/runtime"

	"github.com/rancher/norman/types/convert"
	util "github.com/rancher/rancher/pkg/controllers/managementagent/workload"
	v1 "github.com/rancher/rancher/pkg/generated/norman/core/v1"
	"github.com/rancher/rancher/pkg/ingresswrapper"
	"github.com/rancher/rancher/pkg/types/config"
	"github.com/sirupsen/logrus"
	corev1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/labels"
)

// This controller is responsible for monitoring ingress and
// creating services for them if the service is missing
// Creation wo
    
func generateExpectedServices(state map[string]string, obj *ingresswrapper.CompatIngress) (map[string]ingressService, error) {
	var err error
	rtn := map[string]ingressService{}
	for _, r := range obj.Spec.Rules {
		host := r.Host
		if r.HTTP == nil {
			continue
		}
		for _, b := range r.HTTP.Paths {
			key := GetStateKey(obj.GetName(), obj.GetNamespace(), host, b.Path, convert.ToString(b.Backend.Service.Port.Number))
			if workloadIDs, ok := state[key]; ok {
				rtn[b.Backend.Service.Name], err = generateIngressService(b.Backend.Service.Name, b.Backend.Service.Port.Number, workloadIDs)
				if err != nil {
					return nil, err
				}
			}
		}
	}
	if obj.Spec.DefaultBackend != nil {
		key := GetStateKey(obj.GetName(), obj.GetNamespace(), "", "/", convert.ToString(obj.Spec.DefaultBackend.Service.Port.Number))
		if workloadIDs, ok := state[key]; ok {
			rtn[obj.Spec.DefaultBackend.Service.Name], err = generateIngressService(obj.Spec.DefaultBackend.Service.Name, obj.Spec.DefaultBackend.Service.Port.Number, workloadIDs)
			if err != nil {
				return nil, err
			}
		}
	}
	return rtn, nil
}