...

Source file src/github.com/redhat-developer/odo/pkg/dev/common/common.go

Documentation: github.com/redhat-developer/odo/pkg/dev/common

     1  package common
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/devfile/library/v2/pkg/devfile/generator"
     7  
     8  	corev1 "k8s.io/api/core/v1"
     9  )
    10  
    11  // GetFirstContainerWithSourceVolume returns the first container that set mountSources: true as well
    12  // as the path to the source volume inside the container.
    13  // Because the source volume is shared across all components that need it, we only need to sync once,
    14  // so we only need to find one container. If no container was found, that means there's no
    15  // container to sync to, so return an error
    16  func GetFirstContainerWithSourceVolume(containers []corev1.Container) (string, string, error) {
    17  	for _, c := range containers {
    18  		for _, env := range c.Env {
    19  			if env.Name == generator.EnvProjectsSrc {
    20  				return c.Name, env.Value, nil
    21  			}
    22  		}
    23  	}
    24  
    25  	return "", "", fmt.Errorf("in order to sync files, odo requires at least one component in a devfile to set 'mountSources: true'")
    26  }
    27  

View as plain text