-
Notifications
You must be signed in to change notification settings - Fork 786
/
common_app.go
33 lines (30 loc) · 995 Bytes
/
common_app.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package cmd
import (
jenkinsv1 "github.com/jenkins-x/jx/pkg/apis/jenkins.io/v1"
"github.com/jenkins-x/jx/pkg/kube"
"github.com/jenkins-x/jx/pkg/log"
)
// GetDevEnv gets the Development Enviornment CRD as devEnv,
// and also tells the user whether the development environment is using gitOps
func (o *CommonOptions) GetDevEnv() (gitOps bool, devEnv *jenkinsv1.Environment) {
// We're going to need to know whether the team is using GitOps for the dev env or not,
// and also access the team settings, so load those
jxClient, ns, err := o.JXClientAndDevNamespace()
if err != nil {
if o.Verbose {
log.Errorf("Error loading team settings. %v\n", err)
}
return false, &jenkinsv1.Environment{}
} else {
devEnv, err := kube.GetDevEnvironment(jxClient, ns)
if err != nil {
log.Errorf("Error loading team settings. %v\n", err)
return false, &jenkinsv1.Environment{}
}
gitOps := false
if devEnv.Spec.Source.URL != "" {
gitOps = true
}
return gitOps, devEnv
}
}