// ValidiateSideCar validates that dapr side car is running in dapr enabled pods
ValidiateSideCar validates that dapr side car is running in dapr enabled pods
// ValidiateSideCar validates that dapr side car is running in dapr enabled pods
func (m *AppManager) ValidiateSideCar() (bool, error) {
	if !m.app.DaprEnabled {
		return false, fmt.Errorf("dapr is not enabled for this app")
	}
	podClient := m.client.Pods(m.namespace)
	podList, err := podClient.List(metav1.ListOptions{
		LabelSelector: fmt.Sprintf("%s=%s", TestAppLabelKey, m.app.AppName),
	})
	if err != nil {
		return false, err
	}
	if len(podList.Items) != int(m.app.Replicas) {
		return false, fmt.Errorf("expected number of pods for %s: %d, received: %d", m.app.AppName, m.app.Replicas, len(podList.Items))
	}
	for _, pod := range podList.Items {
		daprdFound := false
		for _, container := range pod.Spec.Containers {
			if container.Name == DaprSideCarName {
				daprdFound = true
			}
		}
		if !daprdFound {
			return false, fmt.Errorf("cannot find dapr sidecar in pod %s", pod.Name)
		}
	}
	return true, nil
}
func ( m * AppManager ) ValidiateSideCar ( ) ( bool , error ) { if ! m . app . DaprEnabled { return false , fmt . Errorf ( " " ) } podClient := m . client . Pods ( m . namespace ) podList , err := podClient . List ( metav1 . ListOptions { LabelSelector : fmt . Sprintf ( " " , TestAppLabelKey , m . app . AppName ) , } ) if err != nil { return false , err } if len ( podList . Items ) != int ( m . app . Replicas ) { return false , fmt . Errorf ( " " , m . app . AppName , m . app . Replicas , len ( podList . Items ) ) } for _ , pod := range podList . Items { daprdFound := false for _ , container := range pod . Spec . Containers { if container . Name == DaprSideCarName { daprdFound = true } } if ! daprdFound { return false , fmt . Errorf ( " " , pod . Name ) } } return true , nil }
ValidiateSideCar validates that dapr side car is running in dapr enabled pods
ValidiateSideCar validates that dapr side car is running in dapr enabled pods
// Filter only 'testapp=appName' labeled Pods // Each pod must have daprd sidecar