...
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
12
13
14
15
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