// BOZO !! Need to deal with ephemeral containers.
BOZO !. Need to deal with ephemeral containers.
// BOZO !! Need to deal with ephemeral containers .
func hasSecret(f Factory, spec *v1.PodSpec, ns, name string, wait bool) (bool, error) {
	for _, c := range spec.InitContainers {
		if containerHasSecret(c, name) {
			return true, nil
		}
	}
	for _, c := range spec.Containers {
		if containerHasSecret(c, name) {
			return true, nil
		}
	}
	saName := spec.ServiceAccountName
	if saName != "" {
		o, err := f.Get("v1/serviceaccounts", client.FQN(ns, saName), wait, labels.Everything())
		if err != nil {
			return false, err
		}
		var sa v1.ServiceAccount
		err = runtime.DefaultUnstructuredConverter.FromUnstructured(o.(*unstructured.Unstructured).Object, &sa)
		if err != nil {
			return false, errors.New("expecting ServiceAccount resource")
		}
		for _, ref := range sa.Secrets {
			if ref.Namespace == ns && ref.Name == name {
				return true, nil
			}
		}
	}
	for _, v := range spec.Volumes {
		if sec := v.VolumeSource.Secret; sec != nil {
			if sec.SecretName == name {
				return true, nil
			}
		}
	}
	return false, nil
}
func hasSecret ( f Factory , spec * v1 . PodSpec , ns , name string , wait bool ) ( bool , error ) { for _ , c := range spec . InitContainers { if containerHasSecret ( c , name ) { return true , nil } } for _ , c := range spec . Containers { if containerHasSecret ( c , name ) { return true , nil } } saName := spec . ServiceAccountName if saName != " " { o , err := f . Get ( " " , client . FQN ( ns , saName ) , wait , labels . Everything ( ) ) if err != nil { return false , err } var sa v1 . ServiceAccount err = runtime . DefaultUnstructuredConverter . FromUnstructured ( o . ( * unstructured . Unstructured ) . Object , & sa ) if err != nil { return false , errors . New ( " " ) } for _ , ref := range sa . Secrets { if ref . Namespace == ns && ref . Name == name { return true , nil } } } for _ , v := range spec . Volumes { if sec := v . VolumeSource . Secret ; sec != nil { if sec . SecretName == name { return true , nil } } } return false , nil }
BOZO !.
BOZO ! .