<commit_before>package entrypoint

import (
	"context"
	"fmt"
	"reflect"
	"sync"

	amb "github.com/datawire/ambassador/pkg/api/getambassador.io/v2"
	"github.com/datawire/ambassador/pkg/consulwatch"
	"github.com/datawire/ambassador/pkg/watt"
	consulapi "github.com/hashicorp/consul/api"
)<commit_msg>(from AES) [entrypoint/consul] reconcile for consul<commit_after>package entrypoint

import (
	"context"
	"fmt"
	"log"
	"reflect"
	"sync"

	amb "github.com/datawire/ambassador/pkg/api/getambassador.io/v2"
	"github.com/datawire/ambassador/pkg/consulwatch"
	"github.com/datawire/ambassador/pkg/kates"
	"github.com/datawire/ambassador/pkg/watt"
	consulapi "github.com/hashicorp/consul/api"
)

func (s *AmbassadorInputs) ReconcileConsul(ctx context.Context, consul *consul) {
	var mappings []*amb.Mapping
	for _, svc := range s.Services {
		ann, ok := svc.GetAnnotations()["getambassador.io/config"]
		if ok {
			objs, err := kates.ParseManifests(ann)
			if err != nil {
				log.Printf("error parsing annotations: %v", err)
			} else {
				for _, o := range objs {
					u, ok := o.(*kates.Unstructured)
					c := convertAnnotation(svc.GetNamespace(), u)
					m, ok := c.(*amb.Mapping)
					if ok && include(m.Spec.AmbassadorID) {
						mappings = append(mappings, m)
					}
				}
			}
		}
	}

	var resolvers []*amb.ConsulResolver
	for _, cr := range s.ConsulResolvers {
		if include(cr.Spec.AmbassadorID) {
			resolvers = append(resolvers, cr)
		}
	}

	for _, m := range s.Mappings {
		if include(m.Spec.AmbassadorID) {
			mappings = append(mappings, m)
		}
	}

	consul.reconcile(s.ConsulResolvers, mappings)
}
{'fraction_non_alphanumeric': 0.1470404984423676, 'fraction_numerical': 0.0012461059190031153, 'mean_word_length': 3.8228228228228227, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2849020', 'n_tokens_mistral': 689, 'n_tokens_neox': 619, 'n_words': 106}