func (pa *PodAggregator) Read() logging.Messages {
	var messages logging.Messages
	checkPod := func(object runtime.Object) {
		pod, err := clients.PodFromUnstructured(object.(*unstructured.Unstructured))
		if err != nil {
			logger.V(3).Infof("Failed to unmarshal Pod event: %v", err)
			return
		}
		if relatedResource(pa.owner, pod) {
			messages = append(messages, pa.checker.Update(pod).MessagesWithSeverity(diag.Warning, diag.Error)...)
		}
	}
	pods, err := pa.lister.List(labels.Everything())
	if err != nil {
		logger.V(3).Infof("Failed to list existing Pods: %v", err)
	} else {
		for _, pod := range pods {
			checkPod(pod)
		}
	}
	return messages
}
Read lists existing Pods and returns any related warning/error messages.
package await
import (
	"sync"
	"k8s.io/apimachinery/pkg/labels"
	"k8s.io/client-go/tools/cache"
	"github.com/pulumi/pulumi-kubernetes/provider/v3/pkg/await/states"
	"github.com/pulumi/pulumi-kubernetes/provider/v3/pkg/clients"
	"github.com/pulumi/pulumi-kubernetes/provider/v3/pkg/logging"
	"github.com/pulumi/pulumi/sdk/v3/go/common/diag"
	logger "github.com/pulumi/pulumi/sdk/v3/go/common/util/logging"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
	"k8s.io/apimachinery/pkg/runtime"
	"k8s.io/apimachinery/pkg/watch"
)
type PodAggregator struct {
	sync.Mutex
	stopped bool
	owner ResourceID
	checker *states.StateChecker
	lister cache.GenericLister
	messages chan logging.Messages
}
func NewPodAggregator(owner ResourceID, lister cache.GenericLister) *PodAggregator {
	pa := &PodAggregator{
		stopped:  false,
		owner:    owner,
		lister:   lister,
		checker:  states.NewPodChecker(),
		messages: make(chan logging.Messages),
	}
	return pa
}
func (pa *PodAggregator) Start(informChan <-chan watch.Event) {
	go pa.run(informChan)
}
func (pa *PodAggregator) run(informChan <-chan watch.Event) {
	defer close(pa.messages)
	checkPod := func(object runtime.Object) {
		pod, err := clients.PodFromUnstructured(object.(*unstructured.Unstructured))
		if err != nil {
			logger.V(3).Infof("Failed to unmarshal Pod event: %v", err)
			return
		}
		if relatedResource(pa.owner, pod) {
			messages := pa.checker.Update(pod).MessagesWithSeverity(diag.Warning, diag.Error)
			if len(messages) > 0 {
				pa.messages <- messages
			}
		}
	}
	for {
		if pa.stopping() {
			return
		}
		event := <-informChan
		if event.Object == nil {
			continue
		}
		checkPod(event.Object)
	}
}